Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse C/C function 'printf' could not be resolved

Tags:

c++

eclipse

mingw

I'm trying to set up a C/C++ development environment on Eclipse.

I installed the following Eclipse plugins:

  • C/C++ development tools SDK
  • Library API documentation hover help
  • Unit testing support
  • Compiler support

Then download MinGW.

I followed this for set up: Set up Eclipse C++ compiler without auto-install or altering System Path on Windows then:

Menu *Project* ? *Properties* ? *"C/C++ Include Paths and Symbols"* ? *"Add External Include path...". I added these paths:
C:\MinGW\lib\gcc\mingw32\4.4.0\include
C:\MinGW\lib\gcc\mingw32\4.4.0\include\c++
C:\MinGW\lib\gcc\mingw32\4.4.0\include\c++\backward
C:\MinGW\lib\gcc\mingw32\4.4.0\include\c++\mingw32
C:\MinGW\lib\gcc\mingw32\4.4.0\include-fixed

It still gives me a "Function 'printf' could not be resolved" error or any other function for that matter.

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.

like image 407
roshan213 Avatar asked Jan 24 '26 13:01

roshan213


1 Answers

You must include <stdio.h> above your main(). This should solve it:

#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 → IndexRebuild. After rebuild, most likely the symbols will be recognized.

like image 169
BЈовић Avatar answered Jan 26 '26 07:01

BЈовић



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!