Inno Setup Preprocessor: Expression Syntax

ISPP uses C/C++-like expression syntax. It supports simple and compound assignment operators, conditional operator, and sequential evaluation operator. Although ISPP is an interpreter, it does support short circuit boolean evaluation and never evaluates expressions (nor calls any macros mentioned in those expressions) that should not be evaluated due to specific rules (for example, when conditional operator is used, always only 2 out of 3 operands are evaluated).

The ISPPBuiltins.iss file contains many example expressions.

Differences between C and ISPP expression syntax

Data types

There are three types in ISPP: void, integer, and string. Variable of void type is declared by just specifying its name after define directive without any value. Such variables should be used with ifdef directive or Defined function.

If "allow undeclared identifiers" parser option is off (the default state, see pragma), an error is raised when undefined variable is mentioned. Otherwise, it will be treated as a value of type void.

Void is compatible with integer and string in expressions. For example, you can use addition operator with void and integer operands, in this case void operand will be treated as zero. In conjunction with string, void operand is treated as an empty string.

Comments

Comments may be embedded in expression by using a slash and an asterisk. For example:

#emit Var1 /* this is a comment */ + Var2 /* this is a comment */

Also one line comments are supported. Those comments must begin with a semicolon. Whole text after the semicolon up to the end of a line is considered comment.

#emit Var1 + Var2 ; this is a comment

Please note that line spanning feature is triggered before any further processing, thus a comment may occupy more than one line:

#emit Var1 + Var2 ; this is \
  a comment

Extended Macro Call Syntax

In ISPP it is possible to use named arguments when calling user defined macro. Given the declaration:

#define MyMacro(int A = 2, int B = 2) A + B

This macro can be called specifying argument names:

#emit MyMacro(A = 5, B = 10)
#emit MyMacro(B = 3)
#emit MyMacro(B = 10, A = 5)