因此,在我的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'
任何有关如何使其工作的帮助将不胜感激.希望这一切都有某种意义.
/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.
当我使用PuTTY和’g std = c 14’时,该错误不会发生并且程序将完全编译
解决方法
C标准之间有很多变化,因此一个版本中有效的内容不需要在另一个版本中.
g++ defaults to -std=gnu++98
for C++,这是几十年前使用GNU扩展增强的C 98标准(大多数都符合要求).
选择正确的修订:-std = c 1y -pedantic与C 14非常接近.
What changes introduced in C++14 can potentially break a program written in C++11?
原文地址:https://www.jb51.cc/c/119279.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。