- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 9
 
Preprocessor
        IsaacShelton edited this page Mar 21, 2022 
        ·
        1 revision
      
    The preprocessor can be used to conditionally compile sections of code and perform basic computations
Meta directives can be used to invoke the preprocessor
#if use_secret_feature
    useSecret()
#end
See meta directives for a full list of meta directives
Transcendent values are values that are used by the preprocessor and only exist at compile-time.
They can be used in combination with meta directives to interact with the preprocessor.
#if include_secret_feature
    // ...
#end
#set view_area 3.14159265 * view_radius ** 2
#unless is_posix || has_pthread
    // ...
#end
See transcendent values for more information
The preprocessor works on an AST level, text-substitutions are not allowed.
// BAD
if(
#if use_condition_one    // BAD
    is_sky_blue          // BAD
#else                    // BAD
    is_grass_green       // BAD
#end){                   // BAD
    // This won't compile
}
// GOOD
#if use_condition_one
should bool = is_sky_blue
#else
should bool = is_grass_green
#end
if should {
    
}