Compiler Directives

Louis

Active Member
Licensed User
Is there any possibility of adding compiler directives to compile certain statements if a MACRO type definition is defined? E.G. like in C:
#define num 1
#if num
// Compile This Code
#else
Compile This Code
#endif

It would help for projects that have debugging statements throughout the program, and if a symbol is not defined, (or macro) then the statements are NOT compiled. What do you think?
 

Louis

Active Member
Licensed User
Hi. It could somehow be implemented, not like C, but in such a way that we could have code compiled based on optional conditions. E.G. Let's say I have a program with some debug code, and I want this code removed before building the release executable. Rather than look through the code for all debug statements, if a variable, one that I choose, isn't defined then code in between the special conditional statements won't be included in the program. This will make executables faster as the program won't have to check if a variable is set to true or false at runtime, but instead it checks the conditions at compiletime, thus excluding any code when compile conditions are false. Make sense anyone?
 

Louis

Active Member
Licensed User
Exactly, But people could use it to have code included or excluded for various reasons, not just for compiling. HTH.
 
Top