KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q68946: NMK Macros Do Not Override Environment Variables

Article: Q68946
Product(s): See article
Version(s): 1.11
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist1.11 | mspl13_basic
Last Modified: 6-FEB-1991

Macros that are created to redefine environment variables (such as
INCLUDE, LIB, and PATH) do not work correctly when the description
file is executed using NMK.COM, rather than NMAKE.EXE.

The description file below, when executed by NMAKE.EXE, will look for
the include files in the directory "E:\C\INCLUDE". If the same
description file is executed by NMK.COM, the include directory will be
determined by the include environment variable.

Sample Code
-----------

INCLUDE=E:\C\INCLUDE

FOO.EXE : FOO.OBJ
   link foo.obj;

FOO.OBJ : FOO.C
   cl /c foo.c

Note: This example will reproduce the problem correctly only if the
following conditions are met.

1. FOO.C exists.
2. FOO.C contains a line of the form:

      #include <INC_FILE.H>

3. INC_FILE.H exists in the directory "E:\C\INCLUDE".
4. INC_FILE.H does not exist in the default include directory.

Finally, NMK does change the variable for arguments that are in the
makefile. Therefore, to work around the problem above, you can use the
following example:

INCLUDE=E:\C\INCLUDE

FOO.EXE : FOO.OBJ
   link foo.obj;

FOO.OBJ : FOO.C
   cl /c /I$(INCLUDE) foo.c






Microsoft Development Utilities
=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.