我肯定缺少一些明显的东西,但是由于某种原因,Microsoft C ++编译器的命令行版本(cl.exe)似乎不支持仅在运行时报告其版本.我们需要这样做来编写makefile,以检查我们工具的用户已安装的编译器版本(它们会获得带有将在本地进行编译的代码的makefile,因此我们无法控制其编译器版本).
I must be missing something really obvious, but for some reason, the command-line version of the Microsoft C++ compiler (cl.exe) does not seem to support reporting just its version when run. We need this to write makefiles that check the compiler version a user of our tool has installed (they get makefiles with code they are to compile themselves locally, so we have no control over their compiler version).
在gcc中,您只需提供选项-v或--version即可打印出漂亮的版本字符串.
In gcc, you just give the option -v or --version to get a nice version string printed.
在cl.exe中,-v错误.
In cl.exe, you get an error for -v.
我已经阅读了MSDN文档和编译器联机帮助,但找不到用于仅打印编译器版本的开关.令人烦恼的是,总是在编译器启动时获得版本...但是您似乎无法仅出于从中获取版本而无法启动编译器.
I have read the MSDN docs and compiler online help, and I cannot find the switch to just print the compiler version. Annoyingly, you always get the version when the compiler starts... but you seem not to be able to start the compiler just to get the version out of it.
使用qmake查找编译器供应商/版本似乎很相似,但仅涉及与简单的海湾合作委员会的情况.
Finding compiler vendor / version using qmake seemed similar, but only deals with the simple case of gcc.
如果有问题,我正在VC ++ Express 2005中尝试此操作.我希望不会,因为最好以独立于编译器版本的方式来检测编译器版本:)
I am trying this with VC++ Express 2005, if that matters. I hoped it would not, as detecting the compiler version is best done in a compiler-version-independent way :)
更新后,回复:
- 不带任何参数运行cl.exe 打印其版本和一些帮助 文本.
- 最像 可移植的获取版本的方法, 跨vc版本.
- 然后您必须 解析多行输出,但是 不太困难.
- 我们在 最后,就可以了.
- Running cl.exe without any arguments prints its version and some help text.
- This looks like the most portable way to get at the version, across vc versions.
- You then have to parse a multi-line output, but that is not too difficult.
- We did this in the end, and it works.
您确定不能在没有任何输入的情况下运行cl.exe来报告其版本吗?
Are you sure you can't just run cl.exe without any input for it to report its version?
我刚刚在VS 2008、2005和.NET 2003的命令提示符中测试了运行cl.exe的情况,他们都报告了其版本.
I've just tested running cl.exe in the command prompt for VS 2008, 2005, and .NET 2003 and they all reported its version.
2008年:
d:\ Program Files \ Microsoft Visual Studio 9.0 \ VC> cl
d:\Program Files\Microsoft Visual Studio 9.0\VC>cl
用于80x86的Microsoft(R)32位C/C ++优化编译器版本15.00.30729.01
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
对于2005 SP 1(添加了安全标准C ++类):
For 2005, SP 1 (added Safe Standard C++ classes):
C:\ Program Files \ Microsoft Visual Studio 8 \ VC> cl
C:\Program Files\Microsoft Visual Studio 8\VC>cl
用于80x86的Microsoft(R)32位C/C ++优化编译器版本14.00.50727.762
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
2005年:
C:\ Program Files \ Microsoft Visual Studio 8 \ VC> cl
C:\Program Files\Microsoft Visual Studio 8\VC>cl
用于80x86的Microsoft(R)32位C/C ++优化编译器版本14.00.50727.42
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
对于.NET 2003:
For .NET 2003:
用于80x86的Microsoft(R)32位C/C ++优化编译器版本13.10.6030
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
编辑
对于2010年,它将遵循以下原则:
For 2010, it will be along the line of:
用于80x86的Microsoft(R)32位C/C ++优化编译器版本16.XX.YYYYY.ZZ
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.XX.YYYYY.ZZ for 80x86
或取决于目标平台
用于x64的Microsoft(R)C/C ++优化编译器版本16.XX.YYYYY.ZZ
Microsoft (R) C/C++ Optimizing Compiler Version 16.XX.YYYYY.ZZ for x64
2012年:
Microsoft(R)C/C ++优化编译器版本17.XX.YYYYY.ZZ为$$$
Microsoft (R) C/C++ Optimizing Compiler Version 17.XX.YYYYY.ZZ for $$$
其中$$$是目标平台(例如x86,x64,ARM),而XX,YYYYY和ZZ是次要版本号.
where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX, YYYYY, and ZZ are minor version numbers.
2013年:
Microsoft(R)C/C ++优化编译器版本18.XX.YYYYY.ZZ为$$$
Microsoft (R) C/C++ Optimizing Compiler Version 18.XX.YYYYY.ZZ for $$$
其中$$$是目标平台(例如x86,x64,ARM),而XX,YYYYY和ZZ是次要版本号.
where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX, YYYYY, and ZZ are minor version numbers.
对于2015年:
Microsoft(R)C/C ++优化编译器版本19.XX.YYYYY for $$$
Microsoft (R) C/C++ Optimizing Compiler Version 19.XX.YYYYY for $$$
其中$$$$是目标平台(例如x86,x64,ARM),而XX和YYYYY是次要版本号.
where $$$ is the targeted platform (e.g. x86, x64, ARM), and XX and YYYYY are minor version numbers.
更多推荐
从命令行查找Microsoft C ++编译器的版本(用于makefile)
发布评论