If the compiler has some command-line flags and the code has some pragmas that are incompatible with those flags, which one will be used?
To be clearer: I am compiling with g++ -g -O2 -std=gnu++17 -static {files}
– GCC version g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0.
If I write in my code #pragma GCC optimize("Ofast")
, will the final code be compiled with -O2
or with -Ofast
?
That depends on if it's above or below the pragma.
void this_will_be_compiled_with_O2() { stuff(); }
#pragma GCC optimize("Ofast")
void this_will_be_compiled_with_Ofast() { stuff(); }