I want to generate some random double numbers using default_random_engine and uniform_real_distribution in header random.
I use Eclipse for C/C++ & MinGW to build my project.
- Eclipse version: 4.2.1
- Eclipse CDT C/C++ Development Tools version: 8.1.1.201209170703
- Eclipse CDT GCC Cross Compiler Support version: 1.1.0.201209170703
- MinGW version: 4.6.2(checked using "gcc -v")
When I type std::default_random_engine in the editor, Eclipse prompts me that "Type 'std::default_random_engine' could not be resolved".
I have already configured my project to support C++11 features
- Open Project Properties->C/C++ Build ->Settings->Tool Settings->GCC C++ Compiler->Miscellaneous->Other Flags. Put "-std=c++0x" at the end
- Project Properties->C/C++ General->Preprocessor Include Paths, Macros->[Providers] tab->your Built-in Compiler Settings provider (toolchain dependent). Click on "Workspace Settings" link which gets you to "Settings" property page, select [Discovery] tab and your provider again. There is "Command to get compiler specs", add "-std=c++0x" in there.
Then I wrote a list initialized vector and a range for to test the support of the C++11, the code work fine.
vector<int> ivec = {1, 2, 3};
for (int i : ivec)
cout << i << " ";
cout << endl;
What's wrong with the "std::default_random_engine", what should I do to fix this?