Visual C++对于C++标准的支持不是很完善好像是钦定了的。MS还特意在这里说了些非标准行为[1]以及扩展行为[2]。这就不可避免地会让处女座程序猿感到难受(我不是处女座)。所以,经过一番google/bing之后,你会找到一个很好的VC++编译选项/Za。

我们先来看看/Za选项是什么意思:

The /Za compiler option emits an error for language constructs that are not compatible with ANSI C89 or ISO C++11.

We recommend that you disable language extensions by specifying the /Za option if you plan to port your program to other environments. When /Za is specified, the compiler treats Microsoft extended keywords as simple identifiers, disables the other Microsoft extensions, and automatically defines the __STDC__ predefined macro for C programs.

说得和真的一样,让人非常激动,一颗赛艇。

当然了,事实并非你想得那么完美[手动滑稽.gif]。

你include <windows.h>试一下[蜜汁微笑.avi]。

你要还不死心,看这里

When I encountered that bug (valid code like vector<unique_ptr> triggers compiler errors under /Za; the problem is that /Za performs an elided-copy-constructor accessibility check during move construction when no copy constructor is being called even theoretically), I asked for a fix, but unfortunately the resolution was "won't fix forever". I can confirm that it will not be fixed in VC10 SP1 RTW, and that there are currently no plans to fix it in VC11.

As a result, during VC10's development we stopped testing our C++ Standard Library implementation under /Za, and I no longer consider it to be a supported switch. (We support almost all switches, including the headache-inducing ones like /Gr and /Gz, but we have to draw the line when valid code is broken.)

I also asked for /Za to be removed from VC11, but that won't happen either. (However, I was told that /Wp64, which was deprecated in VC9 and VC10, will be removed from VC11. I don't think that's happened yet so I'll have to ping a compiler dev about it. /Wp64 has always been broken - it suffers from false positives and false negatives and interacts extremely badly with templates - and it has been completely superseded by the existence of x64-targeting compilers.)

补充说明:

【2017/8/10】正确的姿势应该是使用/Zc

---完

[1] Visual C++ 非标行为:https://docs.microsoft.com/en-us/cpp/cpp/nonstandard-behavior

[2] Visual C++扩展行为:https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp

Visual C++没事别启用/Za编译选项的更多相关文章

  1. cocos2d-x分别在Visual Studio和eclipse中设置启用Box2D

    cocos2d-x内嵌有chipmunk和Box2D两个物理库,默认启用的是chipmunk.如果想使用Box2D,可做如下设置.PS:本人所用的版本是cocos2d-x-2.2.5. 一.在Visu ...

  2. 启用SQLite的Data Provider 运行WECOMPANYSITE时遇到ERROR CREATING CONTEXT 'SPRING.ROOT': ERROR THROWN BY A DEPENDENCY OF OBJECT 'SYSTEM.DATA.SQLITE'

    从网上下载的源码WeCompanySite,运行时报错 Error creating context 'spring.root': Error thrown by a dependency of ob ...

  3. VS2012启用SQLite的Data Provider

    VS 2012默认是不带的SQLite的Data Provider,所以无法直接在VS 2012里管理SQLite的数据库,自然也不能在VS里像SQL Server那样直接生成Entity Frame ...

  4. VS2012,VS2013启用SQLite的Data Provider界面显示

    VS2012,VS2013启用SQLite的Data Provider界面显示 VS 2012默认是不带的SQLite的Data Provider,所以无法直接在VS 2012里管理SQLite的数据 ...

  5. Visual C++ 异常(Exception)常见问题 (原文标题:A Visual C++ Exception FAQ)

    Visual C++ 异常(Exception)常见问题 版权:Doug Harrison 2001 – 2007 翻译:magictong(童磊) 2011年3月 原文地址:http://membe ...

  6. 【译】New experimental Razor editor for Visual Studio

    随着 Visual Studio 2019 16.7 Preview 4 的发布,现在可以尝试我们新的实验性 Razor 编辑器,用于本地开发,包括 MVC.Razor Page 和 Blazor.我 ...

  7. vs2008每次build都会重新编译链接 && 项目已经过期

    转自:http://blog.csdn.net/movezzzz/article/details/6816605 无外乎两种情况: 1.时间问题,所创建的文件的时间比如是:2011-09-22 09: ...

  8. c# 使用hook来监控鼠标键盘事件的示例代码

    如果这个程序在10几年前,QQ刚刚兴起的时候,有了这个代码,就可实现盗号了. 当然使用钩子我们更多的是实现"全局快捷键"的需求. 比如 程序最小化隐藏后要"某快捷键&qu ...

  9. exploit writing tutorial 阅读笔记总结

    近日阅读Corelan Team编写的exploit writing tutorial系列,大致了解了一下原理,记了一些笔记.此系列文章有中文翻译版,在看雪论坛上发表. 英文版地址:https://w ...

随机推荐

  1. [转载]EXCEL绝对引用中$A$1、A$1、$A1三个的区别?

    转自:https://zhidao.baidu.com/question/167695289.html EXCEL绝对引用中$A$1.A$1.$A1三个的区别? 符号“$”加在不地方的含义有何不同? ...

  2. Vue-admin工作整理(八): BUS | | 组件通信

    一.父子组件之间通信 思路:定义一个个人组件,个人组件通常需要在前缀统一命名一下,如:AInput,该组件的作用是将编辑框中的内容获取并通过事件提交出去,然后在目标组件(store)中通过双向交互模式 ...

  3. UVA - 11468 (AC自动机+动态规划)

    建立AC自动机,把AC自动机当做一张图,在上面跑L个节点就行了. 参考了刘汝佳的代码,发现可能有一个潜在的Bug--如果模式串中出现了没有指定的字符,AC自动机可能会建立出错. 提供一组关于这个BUG ...

  4. 日常安装chocolatey报错此系统上禁止运行脚本

    查看计算机上的现用执行策略get-executionpolicy  ( 默认:Restricted ) 若要在本地计算机上运行您编写的未签名脚本和来自其他用户的签名脚本,使用以下命令将计算机上的 执行 ...

  5. 在Rancher 1.6上部署Traefik负载均衡器

    一.给Traefik主机打标签 01-给即将部署Traefik的主机节点打上标签.jpg 02-主机打完traefik_lb标签后的状态.jpg 二.在Rancher应用商店中部署Traefik 应用 ...

  6. VS code 推荐插件

    vs code 中eslint语法检测,保存即可格式化 具体查看:(https://www.jianshu.com/p/23a5d6194a4b) { // vscode默认启用了根据文件类型自动设置 ...

  7. 小账本APP——软件项目风险管理及解决办法案例

    小账本APP——软件项目风险管理及解决办法案例 摘要 软件项目风险是指在软件开发过程中遇到的预算和进度等方面的问题以及这些问题对软件项目的影响.软件项目风险会影响项目计划的实现,如果项目风险变成现实, ...

  8. 在vue中使用watch监听对象或数组

    最近发现在vue中使用watch监听对象或者数组时,当数组或者对象只是单一的值改变时,并不会出发watch中的事件. 在找问题过程中,发现当数组使用push一类的方法时,会触发watch,如果只是单一 ...

  9. classList用法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 【分享】JS如何为复制的Web文本添加其他信息

    看到了两篇关于这题的讨论,简单的记录一下!o(* ̄▽ ̄*)ブ 1.  stackoverflow , How to add extra info to copied web text 2.  黑客派, ...