我想在头随机中使用default_random_engine和uniform_real_distribution生成一些随机双数.
我使用Eclipse for C/C++和MinGW来构建我的项目.
当我在编辑器中键入std :: default_random_engine时,Eclipse会提示我"无法解析类型'std :: default_random_engine'".
我已经配置了我的项目以支持C++ 11功能
然后我写了一个列表初始化向量和一个范围来测试C++ 11的支持,代码工作正常.
vector<int> ivec = {1, 2, 3};
for (int i : ivec)
cout << i << " ";
cout << endl;
Run Code Online (Sandbox Code Playgroud)
"std :: default_random_engine"出了什么问题,我该怎么做才能解决这个问题?
UPDATE: It's been a long time since I posted the original answer and it has become outdated. I double-checked today (Mar 15, 2014): in Eclipse Kepler (Build id 20130614-0229) it is sufficient to
add under Project > Properties > C/C++ Build > Settings then on the Tool Settings tab GCC C++ Compiler > Miscellaneous the -std=c++11 flag,
then under Window > Preferences > C/C++ > Build > Settings on the Discovery tab chose CDT GCC Built-in Compiler Settings and add the -std=c++11 flag to Command to get compiler specs. On my machine it looks like this after the change:
${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"
clean and rebuild both your project and your index (Project > C/C++ Index > Rebuild) as Eclipse tends to cache error messages and show them even though they are gone after changing the settings.
这肯定适用于我的机器.如果它没有在你的上面,那么你可能想要对此有所了解:虽然我不确定这种方法的正确性,也不是必须在我的机器上进行,但是对Eclipse的C++ 11完全支持.截至2014年3月7日,用户声称它帮助了他们,而上述方法没有.
原帖,现已过时:
这似乎是IDE的错误错误.
单击项目属性,然后单击C/C++ General> Code Analysis>语法和语义错误,并取消选择Type无法解析.
我还必须在我自己的项目中禁用一堆其他语法和语义错误,例如无效参数,无效重载,符号未解析等.这些虚假错误来自Codan.
(您可能必须添加__GXX_EXPERIMENTAL_CXX0X__到您的定义/预处理器宏,但不确定这个.)
| 归档时间: |
|
| 查看次数: |
7542 次 |
| 最近记录: |