Eclipse C/C++问题+Cygwin(抱怨一切)

Eclipse C/C++ problems + Cygwin (complain on everything)

本文关键字:+Cygwin C++ 问题 Eclipse      更新时间:2023-10-16

所以我用Cygwin运行Eclipse C/C++。

我可以顺利运行和编译:

我的test.cpp是:

#include <iostream>
using namespace std;
int main() {
    cout << "This is a demonstration! n";
    sleep(10);
    return 0;
}

我可以用这个makefile成功构建:

**** Build of configuration Release for project HelloWorld ****
make all 
Building file: ../test.cpp
Invoking: Cross G++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.d" -o "test.o"             "../test.cpp"
cygwin warning:
  MS-DOS style path detected: C:UsersDavidcworkspaceHelloWorldRelease
  Preferred POSIX equivalent is: /cygdrive/c/Users/David/cworkspace/HelloWorld/Release
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../test.cpp
Building target: HelloWorld
Invoking: Cross G++ Linker
g++  -o "HelloWorld"  ./test.o   
Finished building target: HelloWorld

**** Build Finished ****

在那之后,我得到了HelloWorld.exe,我可以很好地运行它。

我的问题是,eclipse抱怨一切!上面说我有很多错误:

Description Resource    Path    Location    Type
Function 'sleep' could not be resolved  test.cpp    /HelloWorld line 6  Semantic Error
Symbol 'cout' could not be resolved test.cpp    /HelloWorld line 5  Semantic Error
Symbol 'std' could not be resolved  test.cpp    /HelloWorld line 2  Semantic Error

我的意思是,如果你阅读了代码,情况显然不是这样。

我试过:

Index->Update with modified files
Index->Freshen all files
Index->Create parser log file

这是我在其他网站上找到的提示。

我该如何解决这个问题?!

test.cpp是dos文件还是unix文件?隐藏的字符,比如行尾,可能是个问题。

尝试unix2dos test.cpp