Makefile Preprocessing Operators
For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
Makefile preprocessing expressions can use operators that act on constant values, exit codes from commands, strings, macros, and file-system paths. To evaluate the expression, the preprocessor first expands macros, and then executes commands, and then performs the operations. Operations are evaluated in the order of explicit grouping in parentheses, and then in the order of operator precedence. The result is a constant value.
DEFINED operator is a logical operator that acts on a macro name. The expression
) is true if macroname is defined, even if it does not have an assigned value.
DEFINED in combination with
!ELSE IF is equivalent to
!ELSE IFDEF. However, unlike these directives,
DEFINED can be used in complex expressions.
EXIST operator is a logical operator that acts on a file-system path.
) is true if path exists. The result from
EXIST can be used in binary expressions. If path contains spaces, enclose it in double quotation marks.
To compare two strings, use the equality (
==) operator or the inequality (
!=) operator. Enclose strings in double quotation marks.
Integer constants can use the unary operators for numerical negation (
–), one's complement (
~), and logical negation (
Expressions can use the following operators. The operators of equal precedence are grouped together, and the groups are listed in decreasing order of precedence. Unary operators associate with the operand to the right. Binary operators of equal precedence associate operands from left to right.
|Produces a logical value for the current definition state of macroname.|
|Produces a logical value for the existence of a file at path.|
|Unary logical NOT.|
|Unary one’s complement.|
|Bitwise shift left.|
|Bitwise shift right.|
|Less than or equal.|
|Greater than or equal.|
The bitwise XOR operator (