2013-07-21 80 views
-3

我想产生与使用mersenne_twister_engine的64位的随机数,但是当我尝试包括#include <random>,编译器给了我下面什么是添加<random>头文件的正确方法?

/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options. make: * [fuse.o] Error 1

显示我怎样才能解决这个警告?

+1

你尝试添加-std = C++ 0x或-std = gnu ++ 0x编译器选项?发生了什么? – Johnsyweb

+3

编译器警告消息不是自解释的吗? –

+0

同意我将从下次开始。 –

回答

1

random在C++ 11引入,添加到您的g ++选项:

--std=c++0x 

--std=gnu++0x 

的选择可能是在你的makefile。

+0

没有该选项在我的make文件中不可用。你可以请指导我如何添加该选项。 –

5

... and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

你没读过那一点吗?您需要将其中的一个添加到您的编译器命令行中(或者,如果您使用IDE,则使用IDE用于设置选项的任何方法)。有关C++ 11在gcc支持的详细信息,请参阅here

例如(命令行编译),如果当前的命令是

g++ -o myprog myprog.cpp 

你应该将其更改为类似

g++ -std=c++0x -o myprog myprog.cpp 
+0

你能指导我如何添加? –

+0

@DarshitDave,这取决于你正在构建的_how_(各种IDE,命令行,通过make等命令行)。我已经给出了一个命令行编译的例子。 – paxdiablo

+0

可否请您指导我如何在Makefile中添加相同的选项? –

相关问题