Sunday, May 22, 2011

Enable C++0x Support in GCC

To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. It can be set in in IDE also. The following are the steps to enable GCC's C++0x Support in Code::Blocks run under Linux.

OS: Ubuntu Linux 10.10
IDE: Code::Blocks 10.05

Modify the last Hello World exercise to have some c++0x code.

#include <iostream>
#include <cstdint>
using namespace std;

int main()
{
char16_t f[ ] = u"Hello World"; // prefix the string with u for char16_t
cout << sizeof(f) << endl;
char32_t e[ ] = U"Hello World"; // prefix the string with U for char32_t
cout << sizeof(e) << endl;
return 0;
}




It you build and run it now, it with be full of error, it's C++0x!

To enable C++0x support:

Click Settings -> Compiler and debugger...


Select Global compiler settings on the left, and check to enabe "Have g++ follow the coming C++0xISO C++ language standard [-std=c++0x]", click OK.


After return, now you can clean, rebuild and run your project.

No comments:

Post a Comment