Eclipse "Nothing to Build for Project" Error on Build

Tchaikovsky picture Tchaikovsky · Aug 21, 2014 · Viewed 27.1k times · Source

I realize this has been asked before, on this site and others, but none have provided a satisfactory answer. I'm just starting out with C/C++ and I'm using the Eclipse CDT on Mac. After creating a C project, then creating a source file (with the proper .cpp suffix), and writing a simple "Hello World!" program, I get the following error in the console: "Nothing to build for project [name]". There is nothing wrong with the code, as far as I know.

#include <stdio.h> 

int main() {
    printf("Hello World");
}

I'm pretty sure there is nothing wrong with the gcc configuration or anything, although I am not entirely certain. The source file is saved and appears to be under the project, so I am not sure how to resolve this particular problem.

Any help is appreciated.

Answer

Tchaikovsky picture Tchaikovsky · Aug 21, 2014

The project would not build because it had the .cpp prefix, which implied a C++ file (in a C project). Everything worked when I changed it to .c.