[英]c++11 warning on MacOS
I have clang 13.0.0 on my Mac.我的 Mac 上有 clang 13.0.0。 I'm trying to compile some .cpp
files using the command我正在尝试使用命令编译一些.cpp
文件
g++ file.cpp -o file
But I get this warning message:但我收到此警告消息:
file.cpp:23:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const double &e : timestamp) outFile << std::setprecision(10) << e << "\n";
On the clang documentation is said that c++11 is supported by clang 13. On my terminal running man clang
I find: The default C++ language standard is gnu++14
. On the clang documentation is said that c++11 is supported by clang 13. On my terminal running man clang
I find: The default C++ language standard is gnu++14
.
Typing g++ -v
I get:输入g++ -v
我得到:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Why am I getting this warning?为什么我会收到此警告?
AppleClang defaults to c++98, whereas llvm-clang defaults to the later gnu++14; AppleClang默认为c++98,而llvm-clang默认为后面的gnu++14; to access the c++11 implementation, you must add the flag, --std=c++11
or --std=c++14
.要访问 c++11 实现,您必须添加标志--std=c++11
或--std=c++14
。 cf.参看。 https://opensource.apple.com/source/clang/clang-703.0.29/src/tools/clang/www/cxx_status.html https://opensource.apple.com/source/clang/clang-703.0.29/src/tools/clang/www/cxx_status.html
If you are expecting the gnu g++
, it must be installed separately, because on macOS g++
aliases to clang
, which is the Apple fork of clang known as AppleClang . If you are expecting the gnu g++
, it must be installed separately, because on macOS g++
aliases to clang
, which is the Apple fork of clang known as AppleClang .
If you were expecting llvm-clang
, that also must be separately installed.如果您期待llvm-clang
,那也必须单独安装。 AppleClang 13 ≠ llvm-clang 13. AppleClang 13 ≠ llvm-clang 13。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.