Eclipse C/C 函数“printf”无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19305406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse C/C function 'printf' could not be resolved
提问by roshan213
I'm trying to set up a C/C++ development environment on Eclipse.
我正在尝试在 Eclipse 上设置 C/C++ 开发环境。
I installed the following Eclipse plugins:
我安装了以下 Eclipse 插件:
- C/C++ development tools SDK
- Library API documentation hover help
- Unit testing support
- Compiler support
- C/C++开发工具SDK
- 库 API 文档悬停帮助
- 单元测试支持
- 编译器支持
Then download MinGW.
然后下载MinGW。
I followed this for set up: Set up Eclipse C++ compiler without auto-install or altering System Path on Windowsthen:
我按照此进行设置:Set up Eclipse C++ compiler without auto-install or altering System Path on Windows然后:
Menu *Project* ? *Properties* ? *"C/C++ Include Paths and Symbols"* ? *"Add External Include path...". I added these paths:
C:\MinGW\lib\gcc\mingw32.4.0\include
C:\MinGW\lib\gcc\mingw32.4.0\include\c++
C:\MinGW\lib\gcc\mingw32.4.0\include\c++\backward
C:\MinGW\lib\gcc\mingw32.4.0\include\c++\mingw32
C:\MinGW\lib\gcc\mingw32.4.0\include-fixed
It still gives me a "Function 'printf' could not be resolved" error or any other function for that matter.
它仍然给我一个“无法解析函数'printf'”错误或任何其他与此相关的函数。
Here is the code
这是代码
#include <stdio.h>
int main() {
printf("Hello, World!!!!");
return 0;
}
When I do Ctrl+ Space, Eclipse gives me suggestions for C++ functions, but it gives the same error when I select them. It's probably a simple settings change. It would be really helpful if you could help me figure this out.
当我执行Ctrl+ 时Space,Eclipse 会为我提供 C++ 函数的建议,但是当我选择它们时它会给出相同的错误。这可能是一个简单的设置更改。如果您能帮我解决这个问题,那将非常有帮助。
回答by B?ови?
You must include <stdio.h>
above your main(). This should solve it:
您必须包含<stdio.h>
在 main() 之上。这应该解决它:
#include <stdio.h>
int main() {
printf("Hello World!!!");
return 0;
}
Sometimes, Eclipse's parser gets stupid. You can try reparsing the project. Right click on your project then → Index→ Rebuild. After rebuild, most likely the symbols will be recognized.
有时,Eclipse 的解析器会变得愚蠢。您可以尝试重新解析项目。右键单击您的项目,然后 →索引→重建。重建后,很可能会识别符号。
回答by xorguy
You must include
你必须包括
C:\MinGW\include
to the include directory for using C functions.
到包含目录以使用 C 函数。