News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Code::block how to support C++0x

Started by hqt, November 14, 2011, 02:57:47 PM

Previous topic - Next topic

hqt

Code::Block newest version (I'm using newest version of Nightly Build) with Min GW Complier does not support C++0x. So, how can I update my complier, to use new feature of C++0x, who can tell me, please.

thanks :)

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

zabzonk

Latest GCC version for Windows is available from TDM at http://tdm-gcc.tdragon.net - note that you have to enable the C++11 features with the -std=c++0x command line option, or from the Project Build Options|Compiler Settings tab from within Code::Blocks.

thomas

Adding -std=gnu++0x -U__STRICT_ANSI__ to any MinGW version newer than 4.5 (though 4.6 is obviously preferrable) gives the fewest nasty surprises (i.e. for example C headers will not break).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

hqt

I go to [Settings] [Complier] in GNU GCC Complier, have option: having g++ follow the coming C++Ox ISO C++ language standard [-std=c++0x]. After I checked it, I stll cannot use C++0x feature.
And, I have installed TDM, but don't know how to integrate to Code::Block IDE.

So, who can help me, please.
thanks :)

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

zabzonk

@hqt

Firstly, check that you can build your code from the command line (i.e outside of Code::Blocks).

Then check that your CB toolchain settings are pointing at the up-to-date compiler - go to Settings|Compiler & Debugger, then go to the Toolchain Executables tab and make sure the path in the first field is pointing to the up-to-date TDM installation.

If you still can't compile, compile this simple program:

int main() {
     auto x = 1;
}


and post the resulting build log here.

hqt

#7
@: My code has tested successfully on Microsoft Visual Studio 2010, which supported C++0x.
I have installed newest TDM installation. For example, in D:\C++0x\
a) I go to toolchain Executables tab and typing above path. (and I have tried D:\C++0x\bin\, too) But, when I compiled, nothing compiled yet, mean that Code::block doesn't recognize my installation, yet.
b) If I use old version of MinGW, I still have option: [-std=c++0x] in Compiler Setting tab, but when I compiled, of course Compiler has error :(

@: for your program, when compile, It will have this error:  ISO C++ forbids declaration of 'x' with no type.  (of course !!!)

So, who give me some advice, please.
thanks :)

oBFusCATed

Do you use the correct compiler for you project?
You can check in "Project->Build options->Selected compiler"
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

zabzonk

@hgt

Did you do this;

> Firstly, check that you can build your code from the command line (i.e outside of Code::Blocks).

If you can't get that to work, there is no point in messing with CB settings.

hqt

QuoteDo you use the correct compiler for you project?
I have checked and I'm using GNU C++. is it right ?

QuoteFirstly, check that you can build your code from the command line (i.e outside of Code::Blocks).
I don't know what you mean, but I have tested it on MS Studio 2010 successfully. And my program is very simple, it just tests feature of  C++0x. it just have one line:
void f_function(int&&a){} // this feature just has in C++0x

So, who can solve this problem for me, please.
thanks :)

zabzonk

I can't believe that I have to explain to a programmer what a "command line" is. And I'm not going to.

oBFusCATed

Quote from: hqt on November 17, 2011, 05:35:41 PM
I have checked and I'm using GNU C++. is it right ?
Is this the compiler you've setup to use the new version of MinGW(gcc)?

Quote from: hqt on November 17, 2011, 05:35:41 PM
I don't know what you mean, but I have tested it on MS Studio 2010 successfully. And my program is very simple, it just tests feature of  C++0x. it just have one line:
It means that you should open a cmd.exe window and you should type some commands to compile your code, without an IDE.

p.s. I don't know if this is still true, but MinGW have hardcoded search paths like X:\mingw\ (x can be any of the drive letters)  and if you have other version of the compiler there it takes precedence.
   So you should make sure you have only one version of MinGW on your system.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

zabzonk

You can have multiple versions of MinGW installed (I've currently got 5), but I agree for debugging the users problem getting rid of all but one would be a good idea.

oBFusCATed

Hm, I've not said that you can't have multiple versions of MinGW, have I?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]