Share via


Makefile Preprocessing Directives

Home Page (Projects)Overview (NMAKE Reference)How Do I... Topics (Projects)

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.

!CMDSWITCHES

{+| }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. Letters are not case sensitive and are specified without a slash ( / ). To turn some options on and others off, use separate specifications of !CMDSWITCHES.

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.

!ERRORtext

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.

!MESSAGEtext

Displays text to standard output. Spaces or tabs before text are ignored.

!INCLUDE [<]filename[>]

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.

!IFconstantexpression

Processes statements between !IF and the next !ELSE or !ENDIF if constantexpression evaluates to a nonzero value.

!IFDEFmacroname

Processes statements between !IFDEF and the next !ELSE or !ENDIF if macroname is defined. A null macro is considered to be defined.

!IFNDEFmacroname

Processes statements between !IFNDEF and the next !ELSE or !ENDIF if macroname is not defined.

!ELSE[IFconstantexpression |IFDEFmacroname | IFNDEFmacroname]

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.

!ELSEIF

Synonym for !ELSE IF.

!ELSEIFDEF

Synonym for !ELSE IFDEF.

!ELSEIFNDEF

Synonym for !ELSE IFNDEF.

!ENDIF

Marks the end of an !IF, !IFDEF, or !IFNDEF block. Any text after !ENDIF on the same line is ignored.

!UNDEFmacroname

Undefines macroname.