I am very pleased to find out that GCC 4.6 supports the range-based for loop. I found an experimental release of MinGW 4.6 on xvidvideo.ru, is that a well-known, reliable website? What other options do I have (besides compiling myself from source code)?
2 Answers
I wanted to try out GCC 4.7 using the latest Code::Blocks
under Windows 7.
Here's how I did it for myself, YMMV:
I downloaded the latest Equation GCC file at: ftp://ftp.equation.com/gcc/ and installed it under the directory
C:\gcc\
on my local machine. The installer makes the necessary changes to the path environment variable. Logging off and on will pick them up.I downloaded the
Code::Blocks
latest nightly build at: http://forums.codeblocks.org/index.php?board=20.0 and followed the setup instructions.After following the setup instructions (including about the needed DLL files), and starting C::B for the first time;
I chose 'GNU GCC Compiler', and 'Set as default' for the 'Compilers auto-detection' window.
Under the 'Settings > Compiler... > Compiler settings' tab: I ticked the 'Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]' checkbox on.
Under the 'Settings > Compiler... > Toolchain executables' tab: I changed the 'Compiler's installation directory' entry field to
C:\gcc\bin\
.I changed the names of these files physically located in the
C:\gcc\bin\
directoryi686-pc-mingw32-gcc.exe -=to=- mingw32-gcc.exe i686-pc-mingw32-g++.exe -=to=- mingw32-g++.exe make.exe -=to=- mingw32-make.exe
to match the listed name requirements in
Code::Blocks
. You can simply browse to set the correct files (I just personally preferred renaming to match C::B's entries).
If everything went correctly, you should be able to create this program:
#include <iostream>
#include <vector>
int main() {
using namespace std;
vector<int> my_vec = { 1, 2, 3, 4, 5 };
for (auto x : my_vec) {
cout << x << endl;
}
}
and run it OK under Code::Blocks with F9.
Thanks to everyone for all the excellent work put into bringing this great new language to us. Happy C++0x computing!
Bud Alverson
(sorry for the very basic nature of this post) :)

- 5
- 1

- 101
- 1
- 3
-
Thanks a lot! I would not rename files on disk, but rather change CB settings, but anyway - procedure that you described worked for me, +1 – Andrey Aug 26 '11 at 22:08
I'm not really familiar with the site you linked as it's in Russian. The only other place I've found that offers current snapshots of GCC's build is from Equation Solution. I downloaded gcc4.5.1 from there and it's been working fairly well for me. I haven't tried the 4.6.x release yet however. Rumor has it that gcc 4.6.x is slower than its predecessors.
Please do report back what kind of results you're seeing if you do decide experimenting. I'm curious about what improvements they've done in the 4.6.x series.

- 20,287
- 13
- 71
- 105
-
mingw gcc 4.5.1 (32- and 64-bit) is available from cygwin as well. No idea when they will have builds of 4.6. – Ben Voigt Dec 20 '10 at 14:48
-
2@Ben: the 64-bit builds are from the mingw-w64 project, which works pretty close to GCC development. 4.6 will probably be available when it's officially released, or when I get around to building it and uploading it to the mingw-w64 site `;)` – rubenvb Dec 20 '10 at 19:13
-
@rubenvb: That's awesome. And a **much** safer place for people to download it than some russian site. – Ben Voigt Dec 21 '10 at 03:17
-
@rubenvb I'm wondering why someone hasn't done that already? Surely there must be others out there looking to try it out. @Ben I suppose you could always just run the downloaded mingw through a virus scanner site like virustotal to make sure it's safe. – greatwolf Dec 21 '10 at 03:50
-
@Victor: I have already uploaded a 4.6 build, but by now it's ancient and it was never tested (it could also not reproduce itself). The GCC build system is extremely fragile, and especially on the current dev branch, things break often... Especially on a "less important" target like mingw (which is strange I know, seeing how many Windows users there are and the number of cross-platform projects also building for Windows, but that's GNU for you). the latest is GCC 4.6: link: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/ – rubenvb Dec 21 '10 at 10:13
-
I put some instructions on how to compile it here: http://ra1ndog.wordpress.com/2010/10/22/compiling-gcc-4-6-nightlies-on-windows-with-mingw-and-msys/ someone else used my blog and wrote this in japanese: http://blog.k-tai-douga.com/article/41908808.html – Raindog Jan 28 '11 at 08:21