windows - 从命令提示符获取 Windows nmake 版本?
问题描述
我真的不知道nmake
,但我nmake
在 Windows 10 下使用“x64 Native Tools Command Prompt for VS 2017”;我想从命令提示符中找出这个工具的版本。
我发现了这个:
https://docs.microsoft.com/en-us/cpp/build/reference/batch-mode-rules?view=vs-2019
要检查 NMAKE 版本,请运行 NMAKE 版本 1.62 或更高版本提供的 _NMAKE_VER 宏。此宏返回表示 Visual C++ 产品版本的字符串。
...但我真的不知道如何“运行宏” - 我试过这个:
C:\>nmake _NMAKE_VER
Microsoft (R) Program Maintenance Utility Version 14.16.27026.1
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make '_NMAKE_VER'
Stop.
因此,它删除了类似版本字符串的内容,但仍然存在错误。
因此,我怎样才能nmake
正确地从命令行获取版本?
解决方案
正如 Hans Passant 建议的那样,您可以考虑输入nmake/?
; 这将为您提供您从问题中已经知道的内容,即14.16.27026.1
.
该变量_NMAKE_VER
的目的是允许您从 makefile 中测试版本或nmake
Visual Studio 版本。例如,假设您的 makefile 是:
# Check the first three characters of _NMAKE_VER to
# obtain the Visual Studio version:
!if [cmd /c if "%_NMAKE_VER:~0,3%"=="14." exit 1]
! message Using VS 2017, with NMAKE $(_NMAKE_VER)
!elseif [cmd /c if "%_NMAKE_VER:~0,3%"=="12." exit 1]
! message Using VS 2013, with NMAKE $(_NMAKE_VER)
!else
! message Unknown VS version, with NMAKE $(_NMAKE_VER)
!endif
# Just output _NMAKE_VER:
all:
@echo "Version NMAKE" $(_NMAKE_VER)
然后从 Visual Studio 2017 开发人员命令提示符发出以下命令:
nmake /nologo
将给出(在我的机器上):
Using VS 2017, with NMAKE 14.10.25019.0
Version NMAKE 14.10.25019.0
或者对于 Visual Studio 2013:
Using VS 2013, with NMAKE 12.00.21005.1
Version NMAKE 12.00.21005.1
我们需要使用 DOScmd
来进行检查_NMAKE_VER
,因为nmake
与gmake
有限的字符串操作工具不同。
编辑:上述测试可能无法区分 VS 15 和 VS 17,因为 VS 17nmake
版本号以14
而不是预期的15
.
推荐阅读
- google-sheets - Google 表格 importHTML 删除零并将逗号视为小数
- symfony - 在 Symfony 4 中翻译带有参数的 flash 消息
- c - 如何满足有关 printf() 上不兼容类型的警告
- api - 航班优惠价格、航班优惠搜索、航班创建订单是使用缓存还是实时结果?
- docker - 在 docker 上运行的 Jenkins 构建中的 GOPATH 问题
- c# - c#服务将与邮箱连接,读取最后一个电子邮件文件(microsoft excel文件),此文件(excel文件)需要保存
- mysql - 连接查询中的 MySQL 更新执行非常慢
- mysql - MySQL 程序无法按预期执行
- java - 如何以相反的顺序排列字符串集合,并且必须不区分大小写
- android - 使用 Android.mk 从 com.google.android.material 构建 AppBarLayout