Previous | Contents | Next

5.4 Conditional Compilation

The compiler maintains a list of defined symbols, which can be defined using !define or the /D command line switch. These defined symbols can be used for conditional compilation (using !ifdef) or for symbol replacement (a simple form of macros). To replace a symbol with its value, use ${SYMBOL} (if SYMBOL is not defined, no translation will occur). The translation is first-come-first-served, meaning if you do:

!define symbol1 ${symbol2}

If symbol2 is defined when that line occurs, it will be replaced. Otherwise, any replacing will occur when ${symbol1} is referenced.

Define/conditional compilation related commands:

5.4.1 !define

gflag [value]

This command will add 'gflag' to the global define list. This will have a similar effect as using the /D switch on the command line (only the define only becomes effective after the !define command).

5.4.2 !undef

gflag

Removes an item from the global define list. Note that ${SYMBOL} where SYMBOL is undefined will be translated to "${SYMBOL}".

5.4.3 !ifdef

gflag [bcheck [gflag [...]]]

This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If gflag is globally defined (using !define or the /D switch), then the contained lines will be compiled. Otherwise, they will be skipped. 'bcheck' can be specified as & (boolean and) or | (boolean or) along with more gflags -- precedence is simple, left to right.

5.4.4 !ifndef

gflag [bcheck [gflag [...]]]

The opposite of !ifdef. The lines will be compiled when the gflag has not been defined.

5.4.5 !ifmacrodef

gflag [bcheck [gflag [...]]]

This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If the macro gflag exists, then the contained lines will be compiled. Otherwise, they will be skipped. 'bcheck' can be specified as & (boolean and) or | (boolean or) along with more gflags -- precedence is simple, left to right.

5.4.6 !ifmacrondef

gflag [bcheck [gflag [...]]]

The opposite of !ifmacrodef. The lines will be compiled when the macro gflag does not exist.

5.4.7 !else

[ifdef|ifndef|ifmacrodef|ifmacrondef [...]]

This command allows to easily insert different code when different defines or macros are set. You can create blocks like !ifdef/!else/!endif, !ifdef/!else ifdef/!else/!endif etc.

5.4.8 !endif

This command closes a block started with !ifdef, !ifndef, !ifmacrodef or !ifmacrondef.

5.4.9 !insertmacro

macro_name [parameter] [...]

Inserts the contents of a macro that was created with !macro. If the macro was created with parameters, then you must pass as many parameters to the macro as it requires.

5.4.10 !macro

macro_name [parameter][...]

Creates a macro named 'macro_name'. All lines between the !macro and the !macroend will be saved. To insert the macro later on, use !insertmacro. !macro definitions can have one or more parameters defined. The parameters may be accessed the same way a !define would (e.g. ${PARMNAME}) from inside the macro.

5.4.11 !macroend

Ends a macro that was started with !macro.

Previous | Contents | Next