Eclipse CDT:无法解析符号“cout" [英] Eclipse CDT: Symbol 'cout' could not be resolved
问题描述
错误如上.我有 eclipse 项目中应该包含的所有必要文件:
The error is as above. I have what should be all the necessary files include in the eclipse project:
/usr/include/c++/4.6
/usr/include
/usr/include/linux
/usr/local/include
等等.
我尝试了 std::cout
和 using namespace std;
cout
但它仍然说未解决.
I tried std::cout
and using namespace std;
cout
but it still says unresolved.
我已经导入了 iostream
和 cstdlib
.
I have imported iostream
and cstdlib
.
另外,我使用的是 Ubuntu 12.04 和 Eclipse 3.7.2.
Also, I'm on Ubuntu 12.04 with eclipse 3.7.2.
代码片段:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"
int XPluginStart(char * outName, char * outSig, char * outDesc) {
/* ... */
std::cout << "test" << std::endl;
/* ... */
}
使用命名空间标准;
更新:我从现有代码创建了 eclipse 项目.创建一个新的 C++ 项目修复它.我会接受一个解释现有项目中的哪些设置可能导致这种情况的答案(因此我不必剪切和粘贴我的所有项目).
UPDATE: I had created the eclipse project from existing code. Creating a new c++ project fixes it. I'll accept an answer that explains what setting in the existing project could cause this (so I don't have to cut & paste all my projects).
推荐答案
很可能您的设置中缺少一些特定于系统的包含目录,这使得索引器无法正确解析 iostream,从而导致错误.选择 Index ->Search For Unresolved Includes
在项目的上下文菜单中将为您提供未解析的包含列表,您可以在 /usr/include
中搜索并将包含目录添加到 C++ Include Paths和符号
在项目属性中.
Most likely you have some system-specific include directories missing in your settings which makes it impossible for indexer to correctly parse iostream, thus the errors. Selecting Index -> Search For Unresolved Includes
in the context menu of the project will give you the list of unresolved includes which you can search in /usr/include
and add containing directories to C++ Include Paths and Symbols
in Project Properties.
在我的系统上,我不得不为 bits/c++config.h
添加 /usr/include/c++/4.6/x86_64-linux-gnu
来解决以及更多目录.
On my system I had to add /usr/include/c++/4.6/x86_64-linux-gnu
for bits/c++config.h
to be resolved and a few more directories.
不要忘记在添加包含目录后重建索引(Index -> Rebuild).
Don't forget to rebuild the index (Index -> Rebuild) after adding include directories.
这篇关于Eclipse CDT:无法解析符号“cout"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!