Preprocessor Commands

A preprocessor command removes comments from the source code; expands macros; performs conditional inclusions; and includes other files. It is separated from the programming language itself and takes effect before the file is compiled.

Commands

ResCompiler supports the preprocessor commands listed in the following table. All preprocessor command statements must:

  • Begin with a pound (#) sign (except defined(name)).

  • Contain only the preprocessor command.

  • Be written in lower case (except for strings enclosed in quotes).

  • Command

    Description

    #define name

    Defines the name as 1.

    #define name value

    Sets name to value. If value contains other preprocessor values, they are expanded and used.

    The value can be either numeric, for example, -Dversion=5, or a string enclosed in quotes such as -Dname="Order".

    #undef name

    Undefines the specified macro.

    #if expression

    If the expression evaluates to a nonzero value, the expression is true, and the code following the #if expression is included in the resource file.

    If the expression evaluates to zero, the expression is false, and the code following the #else statement, up to a #endif statement, is included in the resource file.

    If there is no #else defined, then no code is executed.

    Expressions can be complete algebraic expressions and can include arithmetic operators (+,-,*, and /), flag operators (&&, ||, and ~), and use parentheses for grouping.

    #else

    Code to be compiled in an #if expression if the expression is false.

    #endif

    Ends an #if or #else code section.

    defined(name)

    This can be used in an #if expression. If the specified name is currently defined, the defined macro expands to 1, otherwise it expands to 0.

    #include "filename"

    Inserts the file specified by filename at the point the preprocessor is specified. The current directory is searched first followed by the directories given in the -I command line option in the order specified. A maximum of 32 files can be included.