I am looking at a CFLAGS of -
CFLAGS=-g -w -D LINUX -O3 -fpermissive
in a Makefile. What does the -D flag do? I see on the man page that
-D name
Predefine name as a macro, with definition 1.
but I don't know how to interpret that. My interpretation is...its making LINUX a macro and only doing -03 and -fpermissive when in a linux environment. Is that right? If not, then what? Thanks for any help
(debug) Inserting the `g' flag tells the compiler to insert more information about the source code into the executable than it normally would. This makes use of a debugger such as gdb much easier, since it will be able to refer to variable names that occur in the source code.
-g requests that the compiler and linker generate and retain source-level debugging/symbol information in the executable itself.
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker.
It is equivalent to adding the statement #define LINUX 1
in the source code of the file that is being compiled. It does not have any effect on other compilation flags. The reason for this is it's an easy way to enable #ifdef
statements in the code. So you can have code that says:
#ifdef LINUX foo; #endif
It will only be enabled if that macro is enabled which you can control with the -D
flag. So it is an easy way to enable/disable conditional compilation statements at compile time without editing the source file.
It doesn't have anything to do with -O3
. Basically, it means the same as
#define LINUX 1
at the beginning of the compiled file.
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