468,512 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Compiler flags

Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.

Sep 10 '06 #1
20 8780

spasmous wrote:
Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.
There's a chap called Google who can be contacted at
http://www.google.com - he knows all about that sort of thing.

Sep 10 '06 #2
J. J. Farrell said:
>
spasmous wrote:
>Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.

There's a chap called Google who can be contacted at
http://www.google.com - he knows all about that sort of thing.
That's like claiming that Mr Yellow Pages knows all about how to clean
drains, bake bread, drive taxis, and issue passports.

Google is a search engine, not an oracle. It doesn't know anything about
Linux, C++, or compiler flags. In fact, it knows little more than which
words appear on which Web sites. An intelligent Googler is well aware that
there is an awful lot of misinformation on the Web, for which Google cannot
reasonably be held responsible. Caveat surfer.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 10 '06 #3
"spasmous" <sp******@gmail.comwrites:
Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.
<OT>
The usual default compiler on Linux is gcc (it's actually a collection
of compilers for several languages, with a shared backend). There's a
command called "g++" that invokes it as a C compiler. Typically "cc"
and "c++" are installed as aliases for "gcc" and "g++", respectively.

If you want to compile C code, use a C compiler: either "gcc" or "cc",
not "g++", or "c++".

All this is explained in gcc documentation, which you can see by
typing "info gcc" or by doing a Google search for "gcc documentation".
</OT>

If you have any more questions about gcc (that aren't answered by the
documentation), try gnu.gcc.help. If you have questions about Linux,
try one of the many Linux newsgroups, or perhaps comp.unix.programmer.
If you have questions about the C language itself, this is the right
place.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 10 '06 #4
spasmous a 嶰rit :
Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.
You should learn to read the documentation.

Just write:

info gcc
or
man gcc

and the associated documentation will tell you ALL compiler
flags, and what they do.

Sep 10 '06 #5

jacob navia wrote:
spasmous a 嶰rit :
Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.

You should learn to read the documentation.

Just write:

info gcc
or
man gcc

and the associated documentation will tell you ALL compiler
flags, and what they do.
Thanks - I didn't realize c++ was an alias of gcc. Sometimes, you know,
you have to compile someone else's programs on a platform that you
don't know. man c++ was my first try, then google on Linux c++ compiler
flags. Neither produced anything obviously useful.

Next was look for the group with most hits on my google search and post
there. Which is what I did. Sorry your NG is not pure enough for you
guys - but thank you for your suggestions.

Sep 10 '06 #6
"spasmous" <sp******@gmail.comwrites:
Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.
Assuming you mean gcc, the appropriate flags are here (from Richard
Heathfield at some point in the past):
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -O3

Jacob Navia recommends adding -Wextra for the latest version of gcc.

Rather unfortunately, you have to fix the spacing yourself.

--
Andrew Poelstra <http://www.wpsoftware.net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
Sep 11 '06 #7
Andrew Poelstra <ap*******@false.sitewrites:
"spasmous" <sp******@gmail.comwrites:
>Can someone point me to a website that lists the compiler flags for the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.

Assuming you mean gcc, the appropriate flags are here (from Richard
Heathfield at some point in the past):
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -O3

Jacob Navia recommends adding -Wextra for the latest version of gcc.

Rather unfortunately, you have to fix the spacing yourself.
<OT>
-Wextra is a newer name for -W. "info gcc" for details.
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 11 '06 #8
Andrew Poelstra said:
Assuming you mean gcc, the appropriate flags are here (from Richard
Heathfield at some point in the past):
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -O3
No, this set is from "those who know me have no need of my name" - all I did
was pinch it. (And he's been looking for it ever since.)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 11 '06 #9
Keith Thompson wrote:
Andrew Poelstra <ap*******@false.sitewrites:
>"spasmous" <sp******@gmail.comwrites:
>>Can someone point me to a website that lists the compiler flags
for the Linux c++ compiler. Yes, I know it's called c++ but I am
using it to compile .c files.

Assuming you mean gcc, the appropriate flags are here (from Richard
Heathfield at some point in the past):
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -O3

Jacob Navia recommends adding -Wextra for the latest version of gcc.

Rather unfortunately, you have to fix the spacing yourself.

<OT>
-Wextra is a newer name for -W. "info gcc" for details.
</OT>
Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com
Warning: Do not use Ultimate-Anonymity
They are worthless spammers that are running a scam.

Sep 11 '06 #10
CBFalconer wrote:
Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard. (Without that option, it still has bugs, but at least it
tries to be conforming.)

Sep 11 '06 #11
Harald van D?k said:
CBFalconer wrote:
>Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.
Why not? All that -Wwrite-strings does is issue an extra diagnostic message
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 11 '06 #12
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.

Why not? All that -Wwrite-strings does is issue an extra diagnostic message
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.
Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}

Sep 11 '06 #13
Harald van D?k said:
Richard Heathfield wrote:
>Harald van D?k said:
CBFalconer wrote:
Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.

Why not? All that -Wwrite-strings does is issue an extra diagnostic
message under certain circumstances, and implementations are allowed to
issue whatever diagnostic messages they like.

Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}
me@here:~/scratchcat foo.c
int main(void) {
if(0) ++*"";
}

me@here:~/scratchmake
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c
foo.c: In function `main':
foo.c:2: warning: increment of read-only location
foo.c:3: warning: control reaches end of non-void function
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -o foo foo.o -lm

See? It still compiles.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 11 '06 #14
Richard Heathfield wrote:
Harald van D?k said:
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
Here is my set, implemented via an alias:

-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.

Why not? All that -Wwrite-strings does is issue an extra diagnostic
message under certain circumstances, and implementations are allowed to
issue whatever diagnostic messages they like.
Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}

me@here:~/scratchcat foo.c
int main(void) {
if(0) ++*"";
}

me@here:~/scratchmake
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c
foo.c: In function `main':
foo.c:2: warning: increment of read-only location
foo.c:3: warning: control reaches end of non-void function
gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -o foo foo.o -lm

See? It still compiles.
Interesting. It doesn't with gcc 3.3.6, 3.4.6, 4.0.3 or 4.1.1.
"increment of read-only location" is an unconditional error in all four
of those versions.

Sep 11 '06 #15
Harald van D議k wrote:
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
>Here is my set, implemented via an alias:
>>
>-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
>
I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.
Why not? All that -Wwrite-strings does is issue an extra diagnostic message
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.

Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}
How can a programme which tries to modify
what might be read-only memory be strictly
conforming ? And what is its return value
supposed to be ?

Sep 11 '06 #16
Spiros Bousbouras wrote:
Harald van D議k wrote:
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
Here is my set, implemented via an alias:
>
-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conformto
any standard.
>
Why not? All that -Wwrite-strings does is issue an extra diagnostic message
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.
Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}

How can a programme which tries to modify
what might be read-only memory be strictly
conforming ?
It can't. This program never tries to modify read-only memory, though.
That's what the "if(0)" is for.
And what is its return value
supposed to be ?
In C99, not returning anything on the initial call to main() is
equivalent to returning 0.

Sep 11 '06 #17
Harald van D議k wrote:
Spiros Bousbouras wrote:
Harald van D議k wrote:
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
>Here is my set, implemented via an alias:
>>
>-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
>
I know you're not the first to recommend it, but please keep in mind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.

Why not? All that -Wwrite-strings does is issue an extra diagnosticmessage
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.
>
Not if they cause a strictly conforming program such as the below to no
longer compile.
>
int main(void) {
if(0) ++*"";
}
How can a programme which tries to modify
what might be read-only memory be strictly
conforming ?

It can't. This program never tries to modify read-only memory, though.
That's what the "if(0)" is for.
Ok , what about the following programme ?

unsigned int rnd(void) {
/* Function which returns a random value
* Assume it is conforming.
*/
}

unsigned int power(unsigned int a , unsigned int b) {
/* This function returns the value of
* a raised to the power b. Also assume
* that it is conforming.
*/
}

int main (void) {
unsigned int x , y , z , n ;
char c[] = "a" ;

x=rnd() ; y=rnd() ;
z=rnd() ; n=rnd() ;

if (n>2 && power(x,n) + power(y,n) ==
power(z,n)) c[0]++ ;
}

Since we know that Fermat's last theorem
is true is this a conforming programme ?

Sep 11 '06 #18
Spiros Bousbouras wrote:
Harald van D議k wrote:
Spiros Bousbouras wrote:
Harald van D議k wrote:
>
Richard Heathfield wrote:
Harald van D?k said:
CBFalconer wrote:
Here is my set, implemented via an alias:
>
-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

I know you're not the first to recommend it, but please keep inmind
that gcc with the -Wwrite-strings option by design does not conform to
any standard.
>
Why not? All that -Wwrite-strings does is issue an extra diagnostic message
under certain circumstances, and implementations are allowed to issue
whatever diagnostic messages they like.

Not if they cause a strictly conforming program such as the below to no
longer compile.

int main(void) {
if(0) ++*"";
}
>
How can a programme which tries to modify
what might be read-only memory be strictly
conforming ?
It can't. This program never tries to modify read-only memory, though.
That's what the "if(0)" is for.

Ok , what about the following programme ?

unsigned int rnd(void) {
/* Function which returns a random value
* Assume it is conforming.
* And that it always returns positive values.
*/
}
>
unsigned int power(unsigned int a , unsigned int b) {
/* This function returns the value of
* a raised to the power b. Also assume
* that it is conforming.
*/
}

int main (void) {
unsigned int x , y , z , n ;
char c[] = "a" ;

x=rnd() ; y=rnd() ;
z=rnd() ; n=rnd() ;

if (n>2 && power(x,n) + power(y,n) ==
power(z,n)) c[0]++ ;
}

Since we know that Fermat's last theorem
is true is this a conforming programme ?
Sep 11 '06 #19
Spiros Bousbouras wrote:
Ok , what about the following programme ?

unsigned int rnd(void) {
/* Function which returns a random value
* Assume it is conforming.
*/
}

unsigned int power(unsigned int a , unsigned int b) {
/* This function returns the value of
* a raised to the power b. Also assume
* that it is conforming.
*/
}

int main (void) {
unsigned int x , y , z , n ;
char c[] = "a" ;
I think you mean
char *c = "a";
since the point is that *c isn't modifiable.
x=rnd() ; y=rnd() ;
z=rnd() ; n=rnd() ;

if (n>2 && power(x,n) + power(y,n) ==
power(z,n)) c[0]++ ;
}

Since we know that Fermat's last theorem
is true is this a conforming programme ?
No, and with the modification given above, not even if the functions
are implemented as your comments suggest. You're not taking into
account the possibility of overflow, nor are you ensuring that x, y and
z can't all be 0 (or other values for which x**n + y**n == z**n is
trivially true). If your if() expression would always evaluate as zero,
the program would be strictly conforming, but if(0) is a much simpler
way to make sure of this.

Sep 11 '06 #20
"spasmous" <sp******@gmail.comwrote in message
news:11*********************@q16g2000cwq.googlegro ups.com...
spasmous a 嶰rit :
Can someone point me to a website that lists the compiler flags for
the
Linux c++ compiler. Yes, I know it's called c++ but I am using it to
compile .c files.
....
Thanks - I didn't realize c++ was an alias of gcc. Sometimes, you
know,
you have to compile someone else's programs on a platform that you
don't know. man c++ was my first try, then google on Linux c++
compiler flags. Neither produced anything obviously useful.
You still haven't explained why you're trying to compile .c files with a
C++ compiler. If it's .c, use gcc (or cc). If it's .cc or .cpp, use
g++ (or c++). C and C++ are different languages, and if you use the
wrong compiler (or linker) you'll have all kinds of headaches.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

--
Posted via a free Usenet account from http://www.teranews.com
Warning: Do not use Ultimate-Anonymity
They are worthless spammers that are running a scam.

Sep 11 '06 #21

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by News | last post: by
7 posts views Thread by ajm | last post: by
1 post views Thread by Neil Zanella | last post: by
21 posts views Thread by polychrom | last post: by
1 post views Thread by mukundan.narayanan | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.