Visual Studio等效于这些G ++标志? [英] Visual Studio equivalent for these G++ flags?

查看:286
本文介绍了Visual Studio等效于这些G ++标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译一个使用CMake的项目,它假定编译器是G ++,但实际上我使用的是Visual Studio 2013.在 CMakeLists.txt 文件中,我遇到了line

  set(CMAKE_CXX_FLAGS$ {CMAKE_CXX_FLAGS} -std = c ++ 11 -Wall -Wextra -pedantic)

我认为我应该用类似于

  if(MSVC)
set(CMAKE_CXX_FLAGS$ {CMAKE_CXX_FLAGS} ????)#这里有什么?
else()
set(CMAKE_CXX_FLAGS$ {CMAKE_CXX_FLAGS} -std = c ++ 11 -Wall -Wextra -pedantic)
endif()

我对Visual Studio的世界相当陌生,所以尽管我知道G ++标志的含义,但我不知道它们的Visual Studio等价物。我认为:


  • -std = c ++ 11 告诉G ++使用C ++ 2011,我认为这是Visual Studio 2013中的默认设置,所以我不认为我需要一个标志。

  • -Wall 似乎可能大致对应于 / W4 ,并且 -Wextra 大致对应于 /壁挂?但在VS上, / Wall 包含 / W4 ,所以 / Wall 就足够了吗?

  • -pedantic 检查是否严格符合C ++标准。



任何人都可以确认使用的标志是Visual Studio吗?

解决方案

我使用的是Visual Studio 2015,但我不希望这些标记有任何重大区别:




  • C ++ 11是标准的,但您应该检查支持C ++ 11/14/17 -page只是为了确定,也许升级到VS2015编译器。

  • Visual Studio有一个Warning-级别,您可以在/ W0- / W4和/ Wall之间进行选择。因此,使用Visual Studio本身,你不能指定/ W4和/ Wall,这导致我得出/ Wall已经足够的结论。

  • 我认为最接近迂腐翻译(sry,德语VS这里)为停用语言扩展名并且是选项/ Za


I am compiling a project that uses CMake which assumes the compiler is G++, but I am actually using Visual Studio 2013. In the CMakeLists.txt file, I encountered the line

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")

I think I ought to replace with something like

if(MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ????")   # what goes here??
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")
endif()

I am fairly new to the world of Visual Studio, so although I know what the G++ flags mean, I don't know their Visual Studio equivalents. I think:

  • -std=c++11 tells G++ to use C++ 2011, which I think is the default in Visual Studio 2013, so I don't think I need a flag for that.
  • -Wall seems like it probably corresponds roughly to /W4, and -Wextra corresponds roughly to /Wall? But on VS, /Wall encompasses /W4, so /Wall is enough on its own?
  • -pedantic checks for strict conformance to C++ standard. No idea what the VS equivalent might be.

Can anyone confirm the right flags to use is Visual Studio?

解决方案

I'm using Visual Studio 2015 but i don't expect any major differences in these flags:

  • C++11 is standard, but you should check the Support for C++11/14/17-page just to be sure and maybe upgrade to VS2015-compiler.
  • Visual Studio has a "Warning-Level" where you can choose between /W0-/W4 and /Wall. So using Visual Studio itself you cant specify both /W4 and /Wall which leads me to the conclusion that /Wall is sufficient.
  • The closest i could find to "pedantic" is something i would translate (sry, german VS here) to "deactivate language-extensions" and is the option /Za

这篇关于Visual Studio等效于这些G ++标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆