Expressions in .mak File Preprocessing
The !IF or !ELSE IF ConstantExpression consists of integer constants (in decimal or C-language notation), string constants, or commands. Use parentheses [()]to group expressions. Expressions use C-style, signed, long-integer arithmetic. Numbers are in 32-bit two's-complement form in the range from – 2147483648 through 2147483647.
Expressions can use operators that act on constant values, exit codes from commands, strings, macros, and file-system paths.
The DEFINED operator is a logical operator that acts on a macro name. The expression DEFINED (MacroName) is true if macroname is defined. DEFINED used in combination with !IF or !ELSE IF is equivalent to !IFDEF or !ELSE IFDEF. However, unlike these directives, DEFINED can be used in complex expressions that use binary logical operators.
The EXIST operator is a logical operator that acts on a file-system path. EXIST (path) is true if path exists. The result from EXIST can be used in binary expressions. If path contains spaces, enclose it in quotation marks (" ").
Integer constants can use the unary operators for numerical negation (–), one's complement (~), and logical negation (!).
The following table shows binary operators that constant expressions can use.
| Operator | Description | Operator | Description |
|---|---|---|---|
| + | Addition | || | Logical OR |
| - | Subtraction | << | Left shift |
| * | Multiplication | >> | Right shift |
| / | Division | == | Equality |
| % | Modulus | != | Inequality |
| & | Bitwise AND | < | Less than |
| | | Bitwise OR | > | Greater than |
| ^ | Bitwise XOR | <= | Less than or equal to |
| && | Logical AND | >= | Greater than or equal to |
To compare two strings, use the equality (==) operator and the inequality (!=) operator. Enclose strings in quotation marks (" ").
To use a command's exit code during preprocessing, specify the command, with any arguments, within square brackets ([ ]). Any macros are expanded before the command is executed. Nmake.exe replaces the command and its arguments with the command's exit code, which can be used in an expression to control preprocessing.
See Also
Last updated on Friday, October 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.