Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: smallB on October 24, 2011, 02:36:59 pm
-
When I tried to create precompiled header following: http://wiki.codeblocks.org/index.php?title=Precompiled_headers
I started getting following error:
||warning: command line option '-Weffc++' is valid for C++/ObjC++ but not for C [enabled by default]|
||warning: command line option '-std=c++0x' is valid for C++/ObjC++ but not for C [enabled by default]|
C:\metaprogramming_excersizes\trying_c_compiler_not_in_toolchain\pr.h|6|error: C++ style comments are not allowed in ISO C90|
||=== Build finished: 1 errors, 2 warnings (0 minutes, 0 seconds) ===|
This project compiled before those steps from the link. Doesn't won't to compile after even though compiler is set to be C++ compiler. Is this a bug in Code::blocks or I'm doing something wrong?
-
Read this: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
-
Hi, I've read that already and cannot find anything relevant in there, can you?
-
Hm, have you enabled the full log? I don't see the real errors in the log. Do you have .c files?
-
Hi this is the entire log from the compilation of a project:
Build started on: 24-10-2011 at 16:28.26
Build ended on: 24-10-2011 at 16:28.27
-------------- Build: Debug in trying_c_compiler_not_in_toolchain ---------------
mingw32-gcc-4.6.1.exe -Wall -fexceptions -g -Wshadow -Winit-self -Wredundant-decls -Wcast-align -Wundef -Wfloat-equal -Winline -Wunreachable-code -Wmissing-declarations -Wmissing-include-dirs -Wswitch-enum -Wswitch-default -Weffc++ -Wmain -pedantic-errors -pedantic -std=c++0x -Wfatal-errors -Wextra -Wall -g -ID:\Libraries\boost_1_47_0\boost_1_47_0 -IC:\metaprogramming_excersizes\trying_c_compiler_not_in_toolchain -IC:\metaprogramming_excersizes\trying_c_compiler_not_in_toolchain -c C:\metaprogramming_excersizes\trying_c_compiler_not_in_toolchain\pr.h -o pr.h.gch
cc1.exe: warning: command line option '-Weffc++' is valid for C++/ObjC++ but not for C [enabled by default]
cc1.exe: warning: command line option '-std=c++0x' is valid for C++/ObjC++ but not for C [enabled by default]
C:\metaprogramming_excersizes\trying_c_compiler_not_in_toolchain\pr.h:6:8: error: C++ style comments are not allowed in ISO C90
compilation terminated due to -Wfatal-errors.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 2 warnings (0 minutes, 0 seconds)
The entire project looks like this:
#include <iostream>
using namespace std;
#include "pr.h"
int main()
{
cout << "Hello world!" << endl;
return 0;
}
#ifndef PR_H_INCLUDED
#define PR_H_INCLUDED
/*Nothing in this file, not even this comment*/
#endif // PR_H_INCLUDED//here cb shows the erroneous line (because of the comment)
No, I do not have .c files.
-
This is nothing to do with CB - it's a feature of MinGW GCC. If you do this from the command line:
mingw32-gcc-4.6.1.exe -std=c++0x d.h
you will get the same error, because you are using the gcc driver, and the driver cannot determine whether it is compiling C++ or C code from the file type, and so opts for C. You need to use the correct driver program, in this case mingw32-g++.exe or simply g++.
It's always a good idea to try compiling from outside CB if you have errors with GCC.
-
Hi Neil, thanks for your reply.
And indeed it works when I've switched to g++, but what if I have features in .h file that use c++11? Then g++ won't recognize them and mingw32-gcc-4.6.1.exe will want to compile them as C. What to do then?
-
If you use the -std=c++0x flag, why would g++ not recognise them?
-
Hi Neil, I'm quite a new user of code::blocks (previously I was using VS but just couldn't work with it anymore - many reasons, don't ask), and it never came to my mind that I can simply pass argument to a g++ to work in c++11 mode. Many thanks for your help.