Compiler Directives

Compiler 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.
But there is a difference:

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.
ChaosPro does not have a preprocessor: In ChaosPro these directives are evaluated during compile time, i.e. at the same time as all the other instructions are compiled.
So these instructions basically are variable definitions and if-else-instructions.
But they have another syntax and – more importantly – they allow you to maintain a completely independent if-else-hierarchy, independent from the blocks of the common language instructions.

Several variables are predefined. These are:

  • ULTRAFRACTAL – defined if ChaosPro is compatible with UltraFractal, i.e. it IS defined
  • CHAOSPRO – defined if the formula runs inside ChaosPro. Maybe another program can use formulas written for ChaosPro as well. In that case you can use this variable to see whether the formula currently is used with ChaosPro or with the other program.
  • UF_VER20 – defined if ChaosPro is compatible with UltraFractal 2, i.e. it IS defined
  • UF_VER30 – defined if ChaosPro is compatible with UltraFractal 3, i.e. it IS defined
  • VERSION300 – defined if ChaosPro can use formulas written for ChaosPro 3.02
  • VERSION310 – defined if ChaosPro can use formulas written for ChaosPro 3.1

Examples:

  ...    #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);  #endif  

Please 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.

Overview