从命令行查找Microsoft C ++编译器的版本(用于makefile)

编程入门 行业动态 更新时间:2024-10-23 04:58:55
本文介绍了从命令行查找Microsoft C ++编译器的版本(用于makefile)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我肯定缺少一些明显的东西,但是由于某种原因,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)

本文发布于:2023-11-10 22:33:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   命令行   版本   makefile   Microsoft

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!