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

发布于 2025-01-08 09:21:28 字数 1727 浏览 1 评论 0原文

所以我用 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:\Users\David\cworkspace\HelloWorld\Release
  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,我可以正常运行。

我的问题是,日食抱怨一切!它说我有很多错误:

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

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

我该怎么解决这个问题呢?!

So im running Eclipse C/C++ with Cygwin.

I can run and compile smoothly:

My test.cpp is:

#include <iostream>
using namespace std;

int main() {
    cout << "This is a demonstration! \n";
    sleep(10);
    return 0;
}

And I can successfully build with this 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:\Users\David\cworkspace\HelloWorld\Release
  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 ****

After that I get HelloWorld.exe which I can run fine.

My problem is, eclipse complain on everything! It says ive got lots of errors:

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

I mean, this is obviously not the case if you read the code.

I have tried:

Index->Update with modified files

Index->Freshen all files

Index->Create parser log file

which was the tips i've found on other websites.

How should I tackle this problem?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

許願樹丅啲祈禱 2025-01-15 09:21:28

test.cpp是dos还是unix文件?隐藏字符(例如行结尾)可能是问题所在。

尝试unix2dos test.cpp

Is the test.cpp a dos or unix file? Hidden characters such line endings could be the issue.

Try unix2dos test.cpp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文