Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable C++0x features in Visual studio? [Initializer Lists support]

I had some code that I developed on Ubuntu and now I am trying to compile it on Windows 7 (MS VS 2010).

vector<float> tmp; .... tmp = {3.0,4.5,9.4}; 

This gives me syntax error

error C2143: syntax error : missing ';' before '{' 

Is this because Visual studio doesn't support this feature ? or should I be enabling some switch in the properties. I have the "Platform Toolset" property set to "v100."

Thank you.

like image 317
Chenna V Avatar asked Feb 25 '11 19:02

Chenna V


People also ask

How to check if Visual c++ build Tools are installed?

To check if Visual C++ redistributables are installed, open Add and Remove Programs and look for the Microsoft Visual C++ Redistributable. If installed, you see "Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.22. 27821".

How to check C++ version in Visual Studio code?

C/C++ configurations# You can view the C/C++ configuration UI by running the command C/C++: Edit Configurations (UI) from the Command Palette (Ctrl+Shift+P). This opens the C/C++ Configurations page. When you make changes here, VS Code writes them to a file called c_cpp_properties.

Where is MSVC compiler?

More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .


1 Answers

The C++0x features are enabled by default on the Visual Studio 2010 C++ compiler. It takes no extra switches for example to use lambdas, auto, etc ... If you're getting that error it's because in all likelyhood it's not supported.

EDIT

Based on this MSDN article, initializer lists are not one of the 6 supported features in 2010

  • http://msdn.microsoft.com/en-us/magazine/ee336130.aspx

the Visual C++ compiler in Visual Studio 2010 enables six C++0x core language features: lambda expressions, the auto keyword, rvalue references, static_assert, nullptr and decltype

like image 106
JaredPar Avatar answered Oct 18 '22 17:10

JaredPar