如何从命令提示符正确获取Windows环境下nmake的版本?
I get where you're coming from—trying to run nmake _NMAKE_VER gives you the version string but also throws that annoying U1073 error, right? The issue here is that NMAKE interprets _NMAKE_VER as a target file it needs to build, hence the fatal error, even though it does spit out the version info first.
Here are two clean ways to get the version without any errors:
Method 1: Print the Macro Directly via Command Line
Use NMAKE's command-line flags to execute an echo command that outputs the _NMAKE_VER macro value. Run this:
nmake /E /C "@echo %_NMAKE_VER%"
Breakdown of the flags:
/E: Ensures built-in macros like_NMAKE_VERare properly resolved/C: Suppresses extra NMAKE status output, so you only get the clean version string (like14.16.27026.1)
Method 2: Use a Temporary Makefile Snippet
If you want more control over the output format, create a quick temporary file (let's call it version.mak) with this content:
!message NMAKE Version: $(_NMAKE_VER)
Then run:
nmake /f version.mak
You'll see a harmless warning about no target specified, but it will clearly print the version string without fatal errors.
One quick note: The version string you saw (Microsoft (R) Program Maintenance Utility Version 14.16.27026.1) is exactly NMAKE's version. The 14.1 maps to VS 2017's toolset (v141), and the 16 is the update build number—_NMAKE_VER just gives you this core version string directly.
内容的提问来源于stack exchange,提问作者sdbbs

