Reputation: 155
What exactly does -DPIC
do when compiling using GCC, and when is it really necessary?
I found that -fpic
and -fPIC
are to generate Position Independent Code. But I could not find anything about -DPIC
.
Upvotes: 6
Views: 3203
Reputation: 30911
This is just a preprocessor macro definition. The GCC manual says:
-D
NAME
Predefine
NAME
as a macro, with definition1
.
-D
NAME=DEFINITION
The contents of
DEFINITION
are tokenized and processed as if they appeared during translation phase three in a#define
directive.
This might be useful if your source code cares whether it's being compiled as position-independent code. For example:
#ifdef PIC
/* ... */
#endif
Upvotes: 8