To fully understand the effects of macros in a description file it is useful to know a little about how NMAKE32 operates. During read-time, NMAKE32 expands all macros except those occurring within a command block. Macros used in command blocks are expanded at run-time, and they will have the last value defined at read-time.

Example:

Given the following description file excerpt:

     MAC = 1
     !IF "$(MAC)" == "1"
     target0:
        @ECHO The value was 1
        @ECHO $$(MAC) is $(MAC)
     !ENDIF
     MAC = 2

returns:

     The value was 1
     $(MAC) is 2

The !IF directive will evaluate to non-zero and execute the command block for target0 because directives are processed at read-time, and at this time the value of MAC is 1. Since MAC is redefined at the end of the description file, the run-time value is now changed to 2. The target0 command block is executed at run-time so the value displayed for the definition of MAC is 2.

Macro references may also be nested. Macros are said to be nested if an expanded macro is used as part of another macro reference.

Example:

If the following macros are defined:

   A = X
   B = Y
   C = Z
   $XYZ = hello

then a reference to the following macro:

   $($A$B$C)

would have the definition hello.


[Back] [Next]