Reputation: 5835
I am using #define ENABLE_FLAG
inside C++ code and correspondingly trying to include a section of code, while ENABLE_FLAG
is defined.
My question is, the particular set of code inside
#ifdef ENABLE_FLAG
....setofcode....
#endif
is evaluated during runtime through #ifdef
check or compiler itself sees the ENABLE_FLAG
during compilation and includes the code?
Upvotes: 2
Views: 2120
Reputation: 16389
#define
settings are compile time, and persist during run time.
Upvotes: 2
Reputation: 249394
#ifdef
and all those other things you see with a #
as the first character on the line are "C preprocessor directives." These are handled even before compilation proper. So there will be no runtime decision made at all--the enabled/disabled block of code is decided at the earliest part of the build process.
Upvotes: 6