Compiler DirectivesCompiler directives are special types of instructions for the compiler. They won't produce any runtime code. Instead, they allow you to instruct the compiler to conditionally compiler parts of the code. ChaosPro implements the following (case sensitive!) directives:
The C/C++ language also has such directives, which at the first glance are identical to the
directives in ChaosPro.
C/C++ compilers have a preprocessor, and these directives are preprocessor directives. And that means,
that these instructions are evaluated by the preprocessor. After that pass the real compilation takes place.
Several variables are predefined. These are:
... #define Testfunc ... void description(void) { #ifdef Testfunc this.caption="AthlonMP-Test"; #else this.caption="Lens Effect"; #endif ... } ...The following example demonstrates that there are independent hierarchies which are evaluated within the same pass... parameter bool bDebug; if (bDebug) { #define DebuggingOn // Will be defined only if the parameter bDebug has been set to true! } i=0; do { ... // perform calculations i=i+1; #ifdef DebuggingOn // if "DebuggingOn" has been defined, the loop should be executed 10 times } while (i>10); #else // if "DebuggingOn" has not been defined, the loop should be executed 100 times } while (i>100); #endifPlease notice that the statement "#define DebuggingOn" will be executed only if "bDebug" has been set to true! If "bDebug" is false, then the compiler will instantly remove the complete if-block, thus the statement "#define DebuggingOn" won't be executed. |