User forums > Using Code::Blocks

Implicit switch to C compiler?

<< < (2/2)

zabzonk:
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.



smallB:
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?

zabzonk:
If you use the -std=c++0x flag, why would g++ not recognise them?

smallB:
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.

Navigation

[0] Message Index

[*] Previous page

Go to full version