GCC - macro containing flag compilation

Is there a macro in GCC that contains compilation flags used to compile a program?

I need something like this:

printf("Compilation flags: %s", __FLAGS__);

For output, for example:

Compilation flags: -02 -g
+4
source share
2 answers

Short answer: None.

A slightly long answer: even if that were the case, your code would not be portable. Projects requiring this kind of function allow the build system to do this, for example. using all the flags in the variable CFLAGSin makeand create a rule by placing all these flags in #define.

+5
source

, , , GCC -fverbose-asm (https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html), , .

, , , .

0

Source: https://habr.com/ru/post/1689577/


All Articles