Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
487 views
in Technique[技术] by (71.8m points)

c++11 - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...