How do i enable 'std=c++0x' from command l

2019-07-02 15:14发布

问题:

I was trying to generate random numbers following a discrete distribution and found this link:

http://www.cplusplus.com/reference/random/discrete_distribution/

I compiled the example given by them and got this error

C:\Users\Anand\Desktop>g++ random.cpp -o rand
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/random:3
5:0,
             from random.cpp:3:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/c++0x_warning.h:32:2: err
or: #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.
random.cpp: In function 'int main()':

This tells that i need to enable '-std=c++0x'. This can be done easily in an IDE but how do i do this via cmd?

回答1:

Like this:

g++ -std=c++0x random.cpp -o random.exe

For what it is worth, your compiler is quite out of date. You would do well to update to a modern version.



标签: c++ eclipse cmd