Partager via


Macros and Nmake.exe (Windows CE 5.0)

Send Feedback

Macros replace a specific string in the .mak file with another string.

Using macros, you can perform the following tasks:

  • Creating a .mak file that can build different projects
  • Specifying options for commands
  • Setting environment variables

You can define your own macros or use the predefined macros for Nmake.exe.

The following example shows the syntax for defining a macro.

MacroName=string

MacroName is a combination of letters, digits, and underscores (_) up to 1,024 characters, and is case-sensitive.

MacroName can contain an invoked macro. If MacroName consists entirely of an invoked macro, the macro being invoked cannot be null or undefined.

The string can be any sequence of zero or more characters. A null string contains zero characters or only spaces or tabs. The string can contain a macro invocation.

A number sign (#) after a definition specifies a comment.

To specify a literal # in a macro, use a caret (^); for example, ^#.

A dollar sign ($) specifies a macro invocation.

To specify a literal $ in a macro, use two dollar signs ($$).

To extend a definition to a new line, end the line with a backslash (\). When the macro is invoked, the backslash and newline characters are replaced with a space.

To specify a literal backslash at the end of the line, precede it with a caret (^), or follow it with a number sign (#) used as a comment specifier.

The following code example shows how to specify a newline character as a literal, by placing a caret (^) at the end of the line.

CMDS = cls^
dir

Both null and undefined macros expand to null strings, but a macro that is defined as a null string is considered defined in preprocessing expressions.

To define a macro as a null string, specify no characters except spaces or tabs after the equal sign (=) in a command line or command file and enclose the null string or definition in quotation marks (" ").

To undefine a macro, use !UNDEF.

Define macros in a command line, command file, .mak file, or the Tools.ini file.

In a .mak file or the Tools.ini file, each macro definition must appear on a separate line and cannot start with a space or tab.

Spaces or tabs around the equal sign (=) are ignored.

All string characters are literal, including surrounding quotation marks (" ") and embedded spaces.

In a command line or command file, spaces and tabs delimit arguments and cannot surround the equal sign.

If string has embedded spaces or tabs, enclose the string itself or the entire macro in quotation marks (" ").

If a macro has multiple definitions, Nmake.exe uses the highest-precedence definition. The following list shows the order of precedence, from highest to lowest:

  1. A macro defined on the command line
  2. A macro defined in a .mak file or include file
  3. An inherited environment-variable macro
  4. A macro defined in the Tools.ini file
  5. A predefined macro, such as CC and AS

Use /E to cause macros that are inherited from environment variables to override .mak file macros with the same name.

Use !UNDEF to override a command line.

See Also

Source Code Configuration File Macros

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.