zoukankan      html  css  js  c++  java
  • Visual C++没事别启用/Za编译选项

    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

  • 相关阅读:
    三个心态做人做学问 沧海
    成功走职场要找准自己的"快捷键" 沧海
    免费离线下载 拂晓风起
    Hibernate 获取某个表全部记录时 奇怪现象 (重复出现某个记录) 拂晓风起
    无法读取mdb 如果连接不了ACCESS mdb文件,就尝试安装MDAC 拂晓风起
    Netbeans 使用 Hibernate 逆向工程 生成hbm和pojo 拂晓风起
    如何点击单选框 radio 后面的文字,选中单选框 拂晓风起
    Java 连接access 使用access文件 不用配置 拂晓风起
    mysql下如何执行sql脚本 拂晓风起
    Hibernate配置access Hibernate 连接 access 拂晓风起
  • 原文地址:https://www.cnblogs.com/wpcockroach/p/7324739.html
Copyright © 2011-2022 走看看