Avi*_*ión 1 c++ compiler-construction compiler-errors compiler-warnings
我在尝试编译此代码时遇到问题:
int *array_aleatorio = new int[8]{0, 1, 2, 3, 4, 5, 6, 7};
Run Code Online (Sandbox Code Playgroud)
这是出现的错误:
main.cpp:315:38:错误:预期';' 在声明结束时
int*array_aleatorio = new int [8] {0,1,2,3,4,5,6,7};
我的一个队友告诉我这可能是因为我没有使用正确的编译器.他正在使用C++11并且有效.我试图安装它没有任何成功.
我正在使用OSX 10.6.8和Netbeans 7.3
我正在使用clang++.

我已经试过这本通过加入解-std=c++11 -stdlib=libc++ -Weverything线项目的编制属性,但它不工作:

这是当我尝试通过添加上面的行来执行它时出现的错误.
clang ++ -std = c ++ 11 -stdlib = libc ++ -Weverything -c -g -std = c ++ 11
-stdlib = libc ++ -Weverything -MMD -MP -MF build/Debug/GNU-MacOSX/main.od -o build/Debug/GNU-MacOSX/main.o
main.cpp clang:warning:编译期间未使用的参数:
' - std = c ++
11'clang :warning:编译期间未使用的参数:' - stdlib = libc ++'警告:未知警告选项'-Weverything'
[-Wunknown-warning-option]警告:未知警告选项
'-Weverything'[-Wunknown-warning-option]错误:
'-std = c ++ 11中的值'c ++ 11'无效"
有人能告诉我如何在OSX中安装C++ 11吗?提前致谢.
您的Xcode的方式过时了.Xcode 3.2.6于2011年发布,包括:
Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
Run Code Online (Sandbox Code Playgroud)
根据发布日期,它没有C++ 11支持并不奇怪.
你想获得Xcode 4.6,其中包括:
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Run Code Online (Sandbox Code Playgroud)
您可能也需要更新您的操作系统 - 10.6.8也是几年之久.