Knowledge Base |

# BUG: Running a Program in NMAKE Fails During Preprocessing

Article ID: 116420

Article Last Modified on 9/30/2003

APPLIES TO

- Microsoft Program Maintenance Utility 1.2
- Microsoft Program Maintenance Utility 1.3
- Microsoft Program Maintenance Utility 1.4

This article was previously published under Q116420

## SYMPTOMS

When running NMAKE on a makefile that executes an external program during preprocessing with the bracket ("[]") syntax, you get the following error message:
fatal error U1023: syntax error in expression
Stop.

## CAUSE

The bracket syntax does not work in NMAKE if the expression being evaluated uses either the subtraction operator ("-") or the bitwise XOR operator ("^").

## STATUS

Microsoft has confirmed this to be a bug in the Microsoft Program Maintenance Utility (NMAKE), versions 1.2, 1.3, and 1.4.
This syntax is no longer documented and it is not supported in Visual C++ for Windows version 1.51 or Visual C++ 32-bit Edition.

## MORE INFORMATION

The bracket syntax can be used to have NMAKE run a program during preprocessing of a makefile. NMAKE replaces the program specification in the makefile with the program's return code. For example, if "Test" is a program that has a return code of 1, after preprocessing, the makefile NMAKE would change the expression

!IF [Test] != 0

to the following:

!IF 1 != 0

The sample code below can be used to duplicate the problem with the bracket syntax and the subtraction and bitwise XOR operators. To reproduce the problem, build the Test program (which simply returns the integer value it has been passed on the command line) and then run NMAKE on the sample makefile.

### Sample Code

    /* TEST.CPP
       Compile options needed: none
    */

       #include <stdio.h>
       #include <stdlib.h>

       int main( int argc, char ** argv )
       {
           return atoi( argv[1] );
       }

       # MAKEFILE
       #
       # Command line options needed: none
       #
       # The expression [Test 4] - 4 should be preprocessed to be
       # 4 - 4, which evaluates to 0 or false. However, NMAKE issues
       # the U1023 error instead.

       all:
       !IF [Test 4] - 4
           @echo Expression evaluated to true
       !ELSE
           @echo Expression evaluated to false
       !ENDIF

Additional query words: 1.20 1.30 1.40 exclusive

Keywords: kb16bitonly KB116420