【发布时间】:2015-06-29 09:37:52
【问题描述】:
我编译了以下程序,但不知道为什么会出现以下错误:
错误:无法识别的命令行选项“-std=c++11”。
我的 gcc 版本是 4.6,我已将 netbeans 中的 c++ 编译器设置为 c++11。
#include <cstdlib>
#include <algorithm>
using namespace std;
template<class T>
void parallel_sort(T* data, int len, int grainsize)
{
if(len < grainsize) // Use grainsize instead of thread count so that we don't e.g. spawn 4 threads just to sort 8 elements.
{
std::sort(data, data + len, std::less<T>());
}
else
{
parallel_sort(data + len/2, len/2, grainsize); // No need to spawn another thread just to block the calling thread which would do nothing.
std::inplace_merge(data, data + len/2, data + len, std::less<T>());
}
}
int main(int argc, char** argv) {
return 0;
}
【问题讨论】:
-
试试
-std=c++0x,gcc4.6可能太老了,不支持-std=c++11 -
我相信4.7.1左右添加了它。
-
@chris, 4.7.0
-
@JonathanWakely,很酷,谢谢。我认为这比我在下学期上课时使用的版本(实际上是两个)小了一个。