In your project workspace, right click on test\Sources\test.c, choose properties in the popup, in the second tab (Build) you can lower the priority for force test.c to be compiled before main.cpp, but the problem is not there. Click on the third tab (Advanced) and put CPP as the compiler variable, not CC given by default for a .c file.
And to avoid a warning, you can cast the string in print_message by (char *), to obtain print_message ((char *)"Hello world!");