Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


C11 initializer lists not working in visual studio 2010/2012


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Enerjak   Members   -  Reputation: 233

Like
0Likes
Like

Posted 07 December 2012 - 10:41 PM

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.

Sponsor:

#2 Radikalizm   Crossbones+   -  Reputation: 2925

Like
2Likes
Like

Posted 07 December 2012 - 10:50 PM

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!


#3 Enerjak   Members   -  Reputation: 233

Like
0Likes
Like

Posted 07 December 2012 - 10:55 PM

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

#4 clb   Members   -  Reputation: 1785

Like
2Likes
Like

Posted 07 December 2012 - 10:55 PM

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 .
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#5 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 08 December 2012 - 01:30 AM

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

I wonder as I wander...

http://www.davesgameoflife.com


#6 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 08 December 2012 - 02:27 AM

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.
[ 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 ]

#7 Ravyne   GDNet+   -  Reputation: 7743

Like
-1Likes
Like

Posted 08 December 2012 - 02:44 AM

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.

#8 aavci   Members   -  Reputation: 137

Like
0Likes
Like

Posted 08 December 2012 - 03:06 AM

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.

#9 clb   Members   -  Reputation: 1785

Like
2Likes
Like

Posted 08 December 2012 - 03:10 AM

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
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#10 aavci   Members   -  Reputation: 137

Like
0Likes
Like

Posted 08 December 2012 - 03:12 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS