How does GCC behave if passed conflicting compiler flags?

后端 未结 1 1188
花落未央
花落未央 2020-12-06 10:47

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). Ho

相关标签:
1条回答
  • 2020-12-06 10:52

    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.

    0 讨论(0)
提交回复
热议问题