我无法访问nmake conditional中的环境变量。我已尝试过以下操作,但它们都会在 !IF
中导致某种语法错误。我还尝试了所有 ==
变体:
!IF $(PROCESSOR_ARCHITECTURE) = "x86"
LIB_SRCS = $(LIB_SRCS) rdrand.cpp
!ENDIF
!IF %PROCESSOR_ARCHITECTURE% = "x86"
LIB_SRCS = $(LIB_SRCS) rdrand.cpp
!ENDIF
!IF [$(PROCESSOR_ARCHITECTURE) = "x86"]
LIB_SRCS = $(LIB_SRCS) rdrand.cpp
!ENDIF
!IF [%PROCESSOR_ARCHITECTURE% = "x86"]
LIB_SRCS = $(LIB_SRCS) rdrand.cpp
!ENDIF
例如,使用!IF $(PROCESSOR_ARCHITECTURE) = "x86"
会产生test.nmake(30) : fatal error U1023: syntax error in expression
。第30行是 !IF
。
MSDN' Makefile Preprocessing Directives页面是预告片,并没有告诉我如何构建表达式(或者我无法找到它)。
如何在nmake条件中访问变量?
如果我按照qxg的建议,则不会执行块中的代码:
!IF "$(PROCESSOR_ARCHITECTURE)" = "x86"
LIB_SRCS = $(LIB_SRCS) rdrand.cpp
!ENDIF
事实上,使用"$(PROCESSOR_ARCHITECTURE)"
打印!MESSAGE
表示它应该匹配。在块中放置 XXX
以导致失败不会产生错误。
以下是变量的转储:
C:\Users\Test>nmake /P
Microsoft (R) Program Maintenance Utility Version 11.00.61030.0
Copyright (C) Microsoft Corporation. All rights reserved.
MACROS:
...
PROCESSOR_ARCHITECTURE = x86
OS = Windows_NT
...
答案 0 :(得分:1)
尝试
!IF "$(PROCESSOR_ARCHITECTURE)" == "x86"