How does GCC behave if passed conflicting compiler flags?

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.

Leave a Comment