C11 initializer lists not working in visual studio 2010/2012

Started by
8 comments, last by aavci 11 years, 4 months ago
Ok, i got a book about C11 and all the new features about it. One of them is initializer lists like:



vector<string> name { "Sonic", "Eggman'" };



but they all give this error:



1 IntelliSense: expected a ';' c:\users\rosario\documents\visual studio 2010\projects\fix\fix\fix.cpp 9 10 Fix



of when dealing with vectors, this:



1 IntelliSense: initialization with '{...}' is not allowed for object of type "std::vector<std::string, std::allocator<std::string>>" c:\users\rosario\documents\visual studio 2010\projects\fix\fix\fix.cpp 9 25 Fix



not sure what to do.
Advertisement
I'd suggest using a different compiler if you want to use C++11 features, Visual Studio has some C++11 support but it's severely lacking when compared to other compilers like GCC.

Some new features including initializer lists have been added in the November CTP for VS2012, but this is pre-release software and can therefore be quite buggy (no word yet on a stable release). They also don't provide an updated version of the standard library with it either, so you wouldn't be able to use these new features with structures defined by the standard library.

I gets all your texture budgets!


I'd suggest using a different compiler if you want to use C++11 features, Visual Studio has some C++11 support but it's severely lacking when compared to other compilers like GCC.

Some new features including initializer lists have been added in the November CTP for VS2012, but this is pre-release software and can therefore be quite buggy (no word yet on a stable release). They also don't provide an updated version of the standard library with it either, so you wouldn't be able to use these new features with structures defined by the standard library.


man, what a buzz kill that is.......thanks, amd apperantly chronos lib is not available for 2010 either
Neither the VC10 or VC11 compilers support initializer lists, see http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx

Your choice is probably quite straightforward:
- Rework the code not to use C++11 initializer lists, or
- Switch to using another compiler that does support them.GCC has initializer lists since GCC 4.4: http://gcc.gnu.org/projects/cxx0x.html . Clang has support for initializer lists since Clang 3.1 http://clang.llvm.org/cxx_status.html . Intel C++ compiler advertizes partial support for initializer lists in 13.0 (I don't know what that means in practice): http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler .
Can one use the VC11 IDE with the GCC or other compilers?

I wonder as I wander...

http://www.davesgameoflife.com


Can one use the VC11 IDE with the GCC or other compilers?

I know you can use the Intel compiler (google may know more); I haven't heard of anyone using GCC with Visual Studio. Also, I'm not sure if changing compilers impacts any Visual Studio features (like debugging) or not.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

I'd suggest using a different compiler if you want to use C++11 features, Visual Studio has some C++11 support but it's severely lacking when compared to other compilers like GCC.


That's not quite a fair statement, at least for VS2012 -- none of the current compilers have full C++ 11 support and each of them implement a different set, so some features might be implemented in one platform and the same feature might be missing from another. Also, some of the compilers that "support" a feature might offer partial support, or support in a way that's not perfectly standards-conforming.

In terms of overall support, the major compilers are not that far apart.

That said, VS lacks support for some of the cooler features like uniform initializers and variadic templates, for which other compilers offer at least some support.

throw table_exception("(? ???)? ? ???");


That's not quite a fair statement, at least for VS2012 -- none of the current compilers have full C++ 11 support and each of them implement a different set, so some features might be implemented in one platform and the same feature might be missing from another. Also, some of the compilers that "support" a feature might offer partial support, or support in a way that's not perfectly standards-conforming.

In terms of overall support, the major compilers are not that far apart.

That said, VS lacks support for some of the cooler features like uniform initializers and variadic templates, for which other compilers offer at least some support.


I am doing cross platform development and MSVC is the only compiler that stops me using the C++11. I can use almost all parts of the standard with GCC, good luck with that with VC.

To be fair VS2012 had some basic support for C++11. November CTP added some more, but it doesn't update the STL and intellisense not working. So basically, it's severely lacking compared to other compilers.

Can one use the VC11 IDE with the GCC or other compilers?


See the vs-tool plugin in my signature if you want to try using MinGW or Clang from Visual Studio. There are also other plugins like that existing. Note however that the plugin is very experimental at this stage, so it can/may require some hacking and tweaking activities. Here's an example of what it looks like in action: https://dl.dropbox.com/u/40949268/code/vs-mingw.png
A more objective comparison: http://cpprocks.com/a-comparison-of-c11-language-support-in-vs2012-g-4-7-and-clang-3-1/

Note that this comparison table doesn't count the November CTP.

This topic is closed to new replies.

Advertisement