I'm using code::blocks w/ minGW.
I get an error message at the first for statement
for(int& n : arr)
Is this an issue with the compiler not being c++0x compliant?
Printable View
I'm using code::blocks w/ minGW.
I get an error message at the first for statement
for(int& n : arr)
Is this an issue with the compiler not being c++0x compliant?
No, it's a problem with you not making a proper for loop.Everything in this color is optional, everything in bold is not.Code:for( initialize_stuff ; truth_test_to_continue_or_not ; increment_stuff )
{
do_stuff();
}
Quzah.
Yes.Quote:
Originally Posted by tabl3six
Hence the mention of C++0x, or rather C++11. Refer to clause 6.5.4.Quote:
Originally Posted by quzah
I don't have the C++ standard. Did they suddenly decide you don't need to form proper loops? I knew there was a reason I didn't like C++. Looks like they just gave me another one.
Quzah.
I just referred to one of the latest draft versions; the final version has not been published yet (I think), and I don't have my copy of the final draft with me.Quote:
Originally Posted by quzah
It certainly is not "suddenly", and it is a proper loop since the language defines what a proper loop is. Basically, it is syntactic sugar for a typical for loop that iterates over some array or container via iterators.Quote:
Originally Posted by quzah
Refer to clause 6.5.4.
Where do I find this?
In the (yet to be published) 2011 edition of the C++ standard. You can find draft versions at the C++ standards committee website.Quote:
Originally Posted by tabl3six
MinGW does indeed support C++11. You need to explicitly enable support for it, however, via a command line. There should also be an option for the compiler in the C::B gui.
Bear in mind that the version of MinGW available in C::B may be a few steps behind the original MinGW port, which in turn may be a few steps behind the current GCC release.
At a command prompt, type
$ gcc --version
and check to see what is supposed to be supported at that version (check the main GCC site).
as salem said, you need to check the version of g++ that you have. 4.6 is the earliest version that supports range-based for, and on a side note, the nullptr keyword.
I've searched for the 4.6 compiler. Doesn't seem to exist. I went to the GCC website and saw a link for it there, but the information is so overwhelming, not sure what to do.
I would think the author of the book wouldn't put examples of code you couldn't easily run. This seems like pulling teeth to me.
Think I'm going to ignor the C++0x chapter.
I don't know if this will work, but have you tried:
Settings -> compiler and debugger -> global compiler settings
In the "compiler flags" tab, there is an option that says, "Have g++ follow the coming C++0x ISO c++ language standard"
Perhaps enabling this option will help?
I doubt that will help unless the OP upgrades the compiler to version 4.6 or higher. The newest compiler I found on the MinGW site was version 4.52.
Jim
I don't think you have many options other than compiling from source now...with mingw.
Btw...if you are adventurous enough...how about installing a Linux distro (on most of which installing gcc-4.6 would be point and click business)?
If you are worried about partitioning try it in a virtual machine.
Elysia:
I did read through the chapter. Thing is I need to run the examples and do the exercises to learn this stuff. I'm going to install Visual Studio 2010 when I get home and maybe some of the commands will work on that.
I really don't want to skip anything. This has just been frustrating. A lot of cool features to try out. I do feel like I'm missing something.
Visual studio 2010 has support for the following C++0x features:
auto
lambdas
rvalue references
decltype
nullptr
static_assert
For more info: Intellisense and Browsing with C++0x - Visual C++ Team Blog - Site Home - MSDN Blogs