Preprocessor

Templates are preprocessed with a simplified C-like preprocessor. The main function of this is for including headers or template fragments within another template. Like in C, all preprocessing occurs before compilation.


#include "path-relative-to-template.h"

Inserts the contents of the given file here. Files are preprocessed recursively and so may contain further preprocessor directives.


#define MACRO_A

#define MACRO_B 1234

#define MACRO_C \
    "Hello" \
    " world"

int i = MACRO_B;    /* 1234 */
string s = MACRO_C; /* "Hello world" */

Defines a preprocessor macro. Like in C, any macros present in the source will be expanded to the value defined here.


#ifdef MACRO
...
#else
...
#endif

#ifndef MACRO
...
#else
...
#endif

Include or exclude a block of the template from compilation depending whether a macro is defined.


#warning warning message
#error error message

Emits a warning message or an error (aborts template processing).