Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...