Eclipse:可以编译,但是CODAN(内部代码分析器)会给出C ++ 11< includes>中的函数错误. [英] Eclipse: Compiles, but CODAN (internal code analyzer) gives errors for functions from C++ 11 <includes>
问题描述
我在eclipse中有以下代码:我正在使用CDT版本运行Indigo SR 2,64位,版本:8.0.2.201202111925生成ID:@ build @我有Java SDK,Android SDK和C ++ CDT.我相信问题只发生在c ++ 11函数上:即使编译器在Eclipse的内部代码分析器CODAN似乎也无法正确找到这些库(我在编译器上有std = C ++ 11标志).
I have the following code in eclipse: I'm running Indigo SR 2, 64bit with CDT Version: 8.0.2.201202111925 Build id: @build@ I have the Java SDK, Android SDK, and C++ CDT. I Believe the problem is only happening with c++ 11 functions: it seems Eclipse's internal code analyzer CODAN is not properly finding the libraries, even though the compiler is (i have the std=C++11 flag on my compilers).
我认为该主题与以下主题有关: http://www.eclipse.org/forums/index.php/t/490066/
I think this topic is related: http://www.eclipse.org/forums/index.php/t/490066/
#include <iostream>
#include <array>
using namespace std;
int main(){
cout << "test";
array<int,5> myints;
int x = 0;
cout << "size of myints: " << myints.size() << std::endl;
cout << "sizeof(myints): " << sizeof(myints) << std::endl;
return 0;
}
,我被告知:
Symbol 'array' could not be resolved
我为什么不编译?我正在CDT和cygwin中使用eclipse靛蓝.我可以根据需要提供更多信息.
Why am I not compiling? I'm using eclipse indigo with the CDT and cygwin. I can provide more info as necessary.
更新:我使用Cygwin GCC和Cygwin PE Parser通过eclipse(锤按钮或右键单击项目,然后单击生成)进行编译.
UPDATE: I compile through eclipse (hammer button or right click project and click build) using Cygwin GCC and the Cygwin PE Parser.
更新2:在indigo中运行会同时导致编辑器错误和编译失败,开普勒给了我这个错误,但似乎可以成功运行和编译.有没有办法使错误在开普勒中消失?另外,我该如何从eclipse中将实际命令传递给编译器?
Update 2: Running in indigo gives both an error in editor and a fail to compile, Kepler gives me the error, but seems to succeed running and compiling. Is there a way to make the error go away in kepler? Also, how would I get the actual command being passed to the compiler from within eclipse?
更新3:更怪异的是,尽管在两个版本的文本编辑器中仍然存在错误,但在开普勒中进行编译后,它现在也可以在靛蓝中进行编译.
Update 3: More weirdness, after compiling in Kepler, it now compiles in indigo as well, though the errors persist in the text editor in both version.
1)有什么方法可以使这些错误更准确地进行编译?
1) Is there a way I can make these errors more accurate to the compile?
2)我可以按include上的f3并查看其来源,那么为什么蚀似乎无法找到数组符号?
2) I can press f3 on the include and view it's source, so why can't eclipse seem to find the array symbol?
3)我还被告知第一个 std :: endl
是'std :: endl'
3) I'm also being told that the first std::endl
is an Invalid overload of 'std::endl'
更新4:我尝试了 std :: tr1 :: array< int,3>arr1 = {1,2,3};
,它仍然告诉我无法解析数组.我已经在我的c/C ++ Build-> Settings-> Cygwin C ++ Compiler-> Miscellaneous-> Other标志中添加了 -std = c ++ 11
.现在显示为: -c -fmessage-length = 0 -std = c ++ 11
但我现在看不到任何变化
Update 4: I tried std::tr1::array<int, 3> arr1 = {1, 2, 3};
and it's still telling me that array cannot be resolved. I've added -std=c++11
to my c/C++ Build -> Settings -> Cygwin C++ Compiler -> Miscellaneous -> Other flags. It now reads: -c -fmessage-length=0 -std=c++11
But I'm seeing no change at this point
更新:这个问题似乎正在解决这个问题: Eclipse C/C ++显示错误但可以编译吗?但是,我已经添加了指向目录"D:/Wamp/cygwin64/lib/gcc/x86_64-pc-cygwin/4.8.2/include"的链接,它没有任何改变...
Update: This question seems to be getting at the problem: Eclipse C/C++ Shows Errors but Compiles? However, I've added a link to the directory "D:/Wamp/cygwin64/lib/gcc/x86_64-pc-cygwin/4.8.2/include" and it hasn't changed anything...
谢谢!
推荐答案
我认为我可以通过更改以下设置来解决此问题:项目->属性-> C/C ++常规/预处理器包含路径,宏等->提供程序(选项卡)
I think I got this resolved by changing the following settings: Project->Properties->C/C++ General/Preprocessor Include Paths, Macros Etc. -> Providers (tab)
然后单击"CDT GCC内置编译器设置"->单击链接工作区设置"再次在获取编译器规格的命令:"下的"CDT GCC内置编译器设置"(再次).添加:-std = c ++ 11"
Then "CDT GCC Built-in Compiler Settings" -> click the link "Workspace Settings"
"CDT GCC Built-in Compiler Settings" (again), under "Command to get compiler specs:"
add: "-std=c++11"
需要刷新,然后红色的小花形消失了.
It took a refresh and then the little red squiggles went away.
这是来源: http://www.eclipse.org/forums/index.php/mv/msg/373462/909018/#msg_909018
我还尝试了以下操作: http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds但这并不完全有效.可能是因为我在Ubuntu上.
I also tried following this: http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds but it didn't exactly work. Probably because I'm on Ubuntu.
这篇关于Eclipse:可以编译,但是CODAN(内部代码分析器)会给出C ++ 11< includes>中的函数错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!