Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

eclipse

cmd

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?

like image 931
Anand Avatar asked Jan 26 '26 14:01

Anand


1 Answers

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.

like image 176
David Heffernan Avatar answered Jan 28 '26 05:01

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!