用c ++编译14

Joe*_*Joe 7 c++ terminal xcode putty c++14

因此,在我的CSE课程中,我们现在可以使用头文件来处理我们正在编写的程序.

不幸的是我无法使用该标头编译终端,它会产生很多错误(只用'g ++'编译).另外,当我在大学时我正在使用PuTTY时,我在使用此标题时会遇到相同的错误.但是,当我用'g ++ -std = c ++ 14'编译时,我没有得到错误.

我已经尝试在我的mac上的终端上使用此命令进行编译,但它说它无法识别c ++ 14部分.

dhcp-10-202-147-243:hw1pr1 Admin$ g++ -std=c++14 hw1pr1.cpp
error: invalid value 'c++14' in '-std=c++14'
Run Code Online (Sandbox Code Playgroud)

任何有关如何使其工作的帮助将不胜感激.希望这一切都有某种意义.

这是我用头文件编译时得到的错误我在终端只用g ++谈论.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ext/hash_map:212:5: warning: 
      Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
      [-W#warnings]
#   warning Use of the header <ext/hash_map> is deprecated.  Migrate to ...
    ^
In file included from read_first_name.cpp:1:
./std_lib_facilities_4.h:43:20: error: no matching function for call to object
      of type 'hash<char *>'
            return hash<char*>()(s.c_str());
                   ^~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ext/__hash:39:12: note: 
      candidate function not viable: 1st argument ('const value_type *'
      (aka 'const char *')) would lose const qualifier
    size_t operator()(char *__c) const _NOEXCEPT
           ^
In file included from read_first_name.cpp:1:
./std_lib_facilities_4.h:112:8: warning: comparison of unsigned expression < 0
      is always false [-Wtautological-compare]
                if (i<0||size()<=i) throw Range_error(i);
                    ~^~
./std_lib_facilities_4.h:118:8: warning: comparison of unsigned expression < 0
      is always false [-Wtautological-compare]
                if (i<0||size()<=i) throw Range_error(i);
                    ~^~
3 warnings and 1 error generated.
Run Code Online (Sandbox Code Playgroud)

当我使用PuTTY和'g ++ std = c ++ 14'时,这个错误不会发生并且程序将完全编译

Ded*_*tor 4

C++ 标准之间存在很多变化,因此在一个修订版中有效的内容不一定在另一修订版中有效。

g++ 默认-std=gnu++98为 C++,这是几十年前的 C++98 标准,通过 GNU 扩展进行了增强(其中大部分是一致的)。

选择正确的版本:-std=c++1y -pedantic非常接近 C++14。

C++14 中引入的哪些更改可能会破坏用 C++11 编写的程序?