Eclipse CDT:无法解析符号'cout' [英] Eclipse CDT: Symbol 'cout' could not be resolved
问题描述
错误如上。我有什么应该是所有必要的文件包括在eclipse项目:
/ usr / include / c ++ / 4.6
/ usr / include
/ usr / include / linux
/ usr / local / include
$ b b
等。
我尝试了 std :: cout
和 using namespace std;
cout
,但它仍然说未解决。
我已导入 iostream
和 cstdlib
p>
此外,我在Ubuntu 12.04上使用eclipse 3.7.2。
代码片段:
#include< cstdio>
#include< cstdlib>
#include< cstring>
#include< iostream>
#includeXPLMDisplay.h
#includeXPLMGraphics.h
int XPluginStart(char * outName,char * outSig,char * outDesc){
/ * ... * /
std :: cout<< test<< std :: endl;
/ * ... * /
}
using namespace std;
更新:我已经从现有代码创建了eclipse项目。创建一个新的c ++项目修复它。我会接受一个答案,解释现有项目中的设置可能会导致这种情况(所以我不必剪切和粘贴我的所有项目)。
很可能你有一些系统特定的包括目录丢失在您的设置,这使索引器不能正确解析iostream,从而错误。选择索引 - >在项目的上下文菜单中搜索未解析的包含
将为您提供未解析的包含列表,您可以在 / usr / include
在项目属性中包含 C ++包含路径和符号
在我的系统上,我不得不添加 / usr / include / c ++ / 4.6 / x86_64-linux-gnu
为 bits / c ++ config.h
在添加include目录后不要忘记重建索引(Index - > Rebuild)。
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
etc.
I tried std::cout
and using namespace std;
cout
but it still says unresolved.
I have imported iostream
and cstdlib
.
Also, I'm on Ubuntu 12.04 with eclipse 3.7.2.
Code snippet:
#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;
/* ... */
}
using namespace std;
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).
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.
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.
Don't forget to rebuild the index (Index -> Rebuild) after adding include directories.
这篇关于Eclipse CDT:无法解析符号'cout'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!