You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preprocessing directives are not case sensitive. The initial exclamation point (!) must appear at the beginning of the line. Zero or more spaces or tabs can appear after the exclamation point, for indentation.
17
-
18
-
**!CMDSWITCHES**
19
-
{**+**|**-**}*option*... Turns each *option* listed on or off. Spaces or tabs must appear before the + or - operator; none can appear between the operator and the [option letters](../build/nmake-options.md). Letters are not case sensitive and are specified without a slash ( / ). To turn some options on and others off, use separate specifications of **!CMDSWITCHES**.
20
-
21
-
Only /D, /I, /N, and /S can be used in a makefile. In Tools.ini, all options are allowed except /F, /HELP, /NOLOGO, /X, and /?. Changes specified in a description block do not take effect until the next description block. This directive updates **MAKEFLAGS**; changes are inherited during recursion if **MAKEFLAGS** is specified.
22
-
23
-
**!ERROR***text*
24
-
Displays *text* in error U1050, then halts NMAKE, even if /K, /I, **.IGNORE**, **!CMDSWITCHES**, or the dash (-) command modifier is used. Spaces or tabs before *text* are ignored.
25
-
26
-
**!MESSAGE***text*
27
-
Displays *text* to standard output. Spaces or tabs before *text* are ignored.
28
-
29
-
**!INCLUDE**[**\<**]*filename*[**>**]
30
-
Reads *filename* as a makefile, then continues with the current makefile. NMAKE searches for *filename* first in the specified or current directory, then recursively through directories of any parent makefiles, then, if *filename* is enclosed by angle brackets (\< >), in directories specified by the **INCLUDE** macro, which is initially set to the INCLUDE environment variable. Useful to pass **.SUFFIXES** settings, **.PRECIOUS**, and inference rules to recursive makefiles.
31
-
32
-
**!IF**`constantexpression`
33
-
Processes statements between **!IF** and the next **!ELSE** or `!ENDIF` if `constantexpression` evaluates to a nonzero value.
34
-
35
-
**!IFDEF***macroname*
36
-
Processes statements between `!IFDEF` and the next **!ELSE** or `!ENDIF` if *macroname* is defined. A null macro is considered to be defined.
37
-
38
-
**!IFNDEF***macroname*
39
-
Processes statements between **!IFNDEF** and the next **!ELSE** or `!ENDIF` if *macroname* is not defined.
Processes statements between **!ELSE** and the next `!ENDIF` if the prior **!IF**, `!IFDEF`, or **!IFNDEF** statement evaluated to zero. The optional keywords give further control of preprocessing.
43
-
44
-
**!ELSEIF**
45
-
Synonym for **!ELSE IF**.
46
-
47
-
**!ELSEIFDEF**
48
-
Synonym for **!ELSE IFDEF**.
49
-
50
-
**!ELSEIFNDEF**
51
-
Synonym for **!ELSE IFNDEF**.
52
-
53
-
`!ENDIF`
54
-
Marks the end of an **!IF**, `!IFDEF`, or **!IFNDEF** block. Any text after `!ENDIF` on the same line is ignored.
Preprocessing directives are not case sensitive. The initial exclamation point (!) must appear at the beginning of the line. Zero or more spaces or tabs can appear after the exclamation point, for indentation.
18
+
19
+
-**!CMDSWITCHES** {**+**|**-**}*option* ...
20
+
21
+
Turns each *option* listed on or off. Spaces or tabs must appear before the + or - operator; none can appear between the operator and the [option letters](../build/nmake-options.md). Letters are not case sensitive and are specified without a slash ( / ). To turn some options on and others off, use separate specifications of **!CMDSWITCHES**.
22
+
23
+
Only /D, /I, /N, and /S can be used in a makefile. In Tools.ini, all options are allowed except /F, /HELP, /NOLOGO, /X, and /?. Changes specified in a description block do not take effect until the next description block. This directive updates **MAKEFLAGS**; changes are inherited during recursion if **MAKEFLAGS** is specified.
24
+
25
+
-**!ERROR***text*
26
+
27
+
Displays *text* in error U1050, then halts NMAKE, even if /K, /I, **.IGNORE**, **!CMDSWITCHES**, or the dash (-) command modifier is used. Spaces or tabs before *text* are ignored.
28
+
29
+
-**!MESSAGE***text*
30
+
31
+
Displays *text* to standard output. Spaces or tabs before *text* are ignored.
32
+
33
+
-**!INCLUDE**[**\<**]*filename*[**>**]
34
+
35
+
Reads *filename* as a makefile, then continues with the current makefile. NMAKE searches for *filename* first in the specified or current directory, then recursively through directories of any parent makefiles, then, if *filename* is enclosed by angle brackets (\< >), in directories specified by the **INCLUDE** macro, which is initially set to the INCLUDE environment variable. Useful to pass **.SUFFIXES** settings, **.PRECIOUS**, and inference rules to recursive makefiles.
36
+
37
+
-**!IF***constant_expression*
38
+
39
+
Processes statements between **!IF** and the next **!ELSE** or **!ENDIF** if *constant_expression* evaluates to a nonzero value.
40
+
41
+
-**!IFDEF***macroname*
42
+
43
+
Processes statements between **!IFDEF** and the next **!ELSE** or **!ENDIF** if *macroname* is defined. A null macro is considered to be defined.
44
+
45
+
-**!IFNDEF***macroname*
46
+
47
+
Processes statements between **!IFNDEF** and the next **!ELSE** or **!ENDIF** if *macroname* is not defined.
Processes statements between **!ELSE** and the next **!ENDIF** if the prior **!IF**, **!IFDEF**, or **!IFNDEF** statement evaluated to zero. The optional keywords give further control of preprocessing.
52
+
53
+
-**!ELSEIF**
54
+
55
+
Synonym for **!ELSE IF**.
56
+
57
+
-**!ELSEIFDEF**
58
+
59
+
Synonym for **!ELSE IFDEF**.
60
+
61
+
-**!ELSEIFNDEF**
62
+
63
+
Synonym for **!ELSE IFNDEF**.
64
+
65
+
-**!ENDIF**
66
+
67
+
Marks the end of an **!IF**, **!IFDEF**, or **!IFNDEF** block. Any text after **!ENDIF** on the same line is ignored.
title: "Makefile Preprocessing Operators | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "11/04/2016"
4
+
ms.date: "06/14/2018"
5
5
ms.technology: ["cpp-tools"]
6
6
ms.topic: "conceptual"
7
7
dev_langs: ["C++"]
@@ -12,55 +12,57 @@ ms.author: "corob"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Makefile Preprocessing Operators
15
-
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.
16
-
17
-
The `DEFINED` operator is a logical operator that acts on a macro name. The expression `DEFINED(`*macroname*`)` is true if *macroname* is defined, even if it does not have an assigned value. `DEFINED` 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.
18
-
19
-
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 double quotation marks.
20
-
21
-
To compare two strings, use the equality (`==`) operator or the inequality (`!=`) operator. Enclose strings in double quotation marks.
22
-
23
-
Integer constants can use the unary operators for numerical negation (`-`), one's complement (`~`), and logical negation (`!`).
24
-
25
-
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.
26
-
27
-
|Operator|Description|
28
-
|--------------|-----------------|
29
-
|`DEFINED(`*macroname*`)`|Produces a logical value for the current definition state of *macroname*.|
30
-
|`EXIST(`*path*`)`|Produces a logical value for the existence of a file at *path*.|
31
-
|||
32
-
|`!`|Unary logical NOT.|
33
-
|`~`|Unary one’s complement.|
34
-
|`-`|Unary negation.|
35
-
|||
36
-
|`*`|Multiplication.|
37
-
|`/`|Division.|
38
-
|`%`|Modulus (remainder).|
39
-
|||
40
-
|`+`|Addition.|
41
-
|`-`|Subtraction.|
42
-
|||
43
-
|`<<`|Bitwise shift left.|
44
-
|`>>`|Bitwise shift right.|
45
-
|||
46
-
|`<=`|Less than or equal.|
47
-
|`>=`|Greater than or equal.|
48
-
|`<`|Less than.|
49
-
|`>`|Greater than.|
50
-
|||
51
-
|`==`|Equality.|
52
-
|`!=`|Inequality.|
53
-
|||
54
-
|`&`|Bitwise AND.|
55
-
|`^`|Bitwise XOR.|
56
-
|`|`|Bitwise OR.|
57
-
|||
58
-
|`&&`|Logical AND.|
59
-
|||
60
-
|`||`|Logical OR.|
61
-
15
+
16
+
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.
17
+
18
+
The **DEFINED** operator is a logical operator that acts on a macro name. The expression **DEFINED(**_macroname_**)** is true if *macroname* is defined, even if it does not have an assigned value. **DEFINED** 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.
19
+
20
+
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 double quotation marks.
21
+
22
+
To compare two strings, use the equality (**==**) operator or the inequality (**!=**) operator. Enclose strings in double quotation marks.
23
+
24
+
Integer constants can use the unary operators for numerical negation (**-**), one's complement (**~**), and logical negation (**!**).
25
+
26
+
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.
27
+
28
+
|Operator|Description|
29
+
|--------------|-----------------|
30
+
|**DEFINED(***macroname***)**|Produces a logical value for the current definition state of *macroname*.|
31
+
|**EXIST(***path***)**|Produces a logical value for the existence of a file at *path*.|
32
+
|||
33
+
|**!**|Unary logical NOT.|
34
+
|**~**|Unary one’s complement.|
35
+
|**-**|Unary negation.|
36
+
|||
37
+
|*****|Multiplication.|
38
+
|**/**|Division.|
39
+
|**%**|Modulus (remainder).|
40
+
|||
41
+
|**+**|Addition.|
42
+
|**-**|Subtraction.|
43
+
|||
44
+
|**\<\<**|Bitwise shift left.|
45
+
|**>>**|Bitwise shift right.|
46
+
|||
47
+
|**\<=**|Less than or equal.|
48
+
|**>=**|Greater than or equal.|
49
+
|**\<**|Less than.|
50
+
|**>**|Greater than.|
51
+
|||
52
+
|**==**|Equality.|
53
+
|**!=**|Inequality.|
54
+
|||
55
+
|**&**|Bitwise AND.|
56
+
|**^**|Bitwise XOR.|
57
+
|**|**|Bitwise OR.|
58
+
|||
59
+
|**&&**|Logical AND.|
60
+
|||
61
+
|**||**|Logical OR.|
62
+
62
63
> [!NOTE]
63
-
> The bitwise XOR operator (`^`) is the same as the escape character, and must be escaped (as `^^`) when it is used in an expression.
64
-
65
-
## See Also
66
-
[Expressions in Makefile Preprocessing](../build/expressions-in-makefile-preprocessing.md)
64
+
> The bitwise XOR operator (**^**) is the same as the escape character, and must be escaped (as **^^**) when it is used in an expression.
65
+
66
+
## See also
67
+
68
+
-[Expressions in Makefile Preprocessing](../build/expressions-in-makefile-preprocessing.md)
0 commit comments