In a project I'm working on, there's a quadruple-nested for loop in a large file I'm trying to optimize I think would benefit from a compiler unroll with -funroll-all-loops. However, when I add this flag to the compiler, it unrolls the other loops the rest of the file and makes the overall program run more slowly. Is there a way (possibly via a #pragma) to apply compiler flags only to certain functions in the file instead of the entire file?
Thanks in advance.
gcc -Wall enables all compiler's warning messages. This option should always be used, in order to generate better code.
'f' stands for 'flag'. -fpic # flag to set position independent code -fno-builtin # don't recognize build in functions ... The technical definition is that 'f' defines "Control the interface conventions used in code generation".
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. Also, the placement of the -l option is significant.
Open your project and then go Project > Build Options > Compiler Flags . You can tick boxes in the "Compiler Flags" tab, and you can write other options in the "Other Options" tab. Do one or the other, e.g. don't tick the "-std=c++98" box and also put "-std=c++11" in the Other Options.
The GCC function attribute optimize
can be used to set an optimization option for a single function:
void foo(int bar) __attribute__((optimize ("unroll-all-loops")))
{
}
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