Jump to content
  • Advertisement
Sign in to follow this  
Enerjak

C11 initializer lists not working in visual studio 2010/2012

This topic is 2202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!