I know that if you execute GCC as such:
gcc -O3 -O2 foo.c
GCC will use the last optimization flag passed (in this case O2
). However, is this true for all flags? For example, if I execute GCC like so:
gcc -mno-sse -msse bar.c
Will it support SSE since that was the last flag passed, or would this result in undefined behavior? My initial experimentation seems to indicate that it will support SSE, but I'm not sure if this is true for all cases.
gcc -Wall enables all compiler's warning messages. This option should always be used, in order to generate better code.
For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified.
By default, GCC limits the size of functions that can be inlined. This flag allows the control of this limit for functions that are explicitly marked as inline (i.e., marked with the inline keyword or defined within the class definition in c++).
This flag enables some optimizations and disables others. This option is enabled by default for the Java front end, as required by the Java language specification. Enable exception handling. Generates extra code needed to propagate exceptions.
Normally later options on the line override ones passed previously, as you mention in your first example. I haven't personally come across any different behaviour for -m
or -f
flags, but I don't know of a specific reference in the documentation.
Note that some options don't behave this way:
$ gcc example.c -DABC -DABC=12
<command-line>: warning: "ABC" redefined
<command-line>: warning: this is the location of the previous definition
So there would need to be a -UABC
in between there to shut that warning up.
As an aside, clang
is particularly good at solving this problem - it will produce a warning if it ignores a command line option, which can help you out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With