This paper discusses the support of the VS2010 compilation tool CL to the C++11 standard, and provides a two-segment code that uses the new C++11 feature to test and compare the compilation with the g++ 4.9.3 compiler. Overall: The VS2010 compiler tool CL section supports the C++11 standard, while g++ 4.9.3 all support the C++11 standard. Although new standards such as c++14 have emerged now, familiarity with the support of the C++11 standard allows us to properly select the compilation tools that meet our needs.
1. Problems arise
One months ago the use of the C + + language for writing algorithms has seen some English versions of algorithmic design and analysis books. An accidental opportunity to discover the C++11 standard, and many different compilers have fully supported the standard. And I used g++ 4.9.3 to compile and experiment with a program with C++11 features, which was one months ago. Since the computer system is Win7, I have the curve to the National salvation, first install Cygwin, and then run the g++ compiler on it.
Suddenly one day, I ask: why do you want to circle? I have already followed VS2010 on my computer, why not use the command-line compilation tool cl.exe? So I turned to use CL to compile some C + + programs. while reading [(Nicolai M. Josuttis, 1999)][1], I used the CL tool to compile and run most of the books in the program, because the digital explanation of the program is the symbol C++98 standard, the CL in VS2010 must be able to compile c++98 program. While reading [the book][1], to the book's website to find errata table, but found that the book has published the latest [second edition][2], the revision of the first version of the increase of more than 300 pages, explained the C++11 standard. I myself also just want to understand c++11 standard, so after reading the first edition, find the second edition to continue reading. The following procedure is available in the book:
//lang/lambda1.cpp #include <functional> #include < Iostream> std :: Function<int ( Span class= "Hljs-keyword" >int , int ) > Returnlambda () {return [] (int x, int y) { return x*y; };} int Main () {auto lf = Returnlambda (); std :: cout << LF ( 6 , 7 ) << std :: Endl;}
This is an example given by the author in order to explain the new features of c++11. I used g++ 4.9.3 to make sure that this program could be compiled, but I continued to use CL in VS2010 to compile the program for inertia. Unexpectedly, the compilation succeeded successfully. C++11 is the new standard for August 2011, and how does the 2010 vs can support it? Did the. NET Framwork update work six months ago? With these questions, I will explore the relevant issues.
2 detailed compiler version of Visual Studio
In order to determine whether I am currently using a real VS2010 version of the compiler, rather than the updated VS2012 cl (because I am updating just the. NET Framework, presumably, VS2010 is more likely), I need to clearly know the VS version with CL The correspondence between compiler versions. The correspondence between them is as follows:
vs Version |
CL Version |
2013 |
18.XX. YYYYY. Zz |
2012 |
17.XX. YYYYY. Zz |
2010 |
16.XX. YYYYY. Zz |
2008 |
15.00.30729.01 |
2005 |
14.00.50727.762 |
2003 |
13.10.6030 |
Then check my CL version for:
From the data in the table above, I can clearly conclude that the CL version I am using is really VS2010. This only shows that, although named VS2010, it may actually be launched later than 2010.
Degree of support for C++11 3 VS2010 cl
Knowing that it is indeed VS2010, the next question needs to know how much it supports c++11. If it is fully supported, then I will be able to use CL directly when I read [second edition][2] instead of turning to g++. There is a detailed introduction to this topic on the MSDN website, see.
It is possible to know that VS2010 support for C++11 is limited, such as it does not support raw String and is tested with the following code:
#include <iostream>namespacestd;/* *Name: rawString.cpp *Purpose: Test whether VS2010 to support * raw string, which is C++ new feature. */int main() { cout << R"nc(a b\nc()" )nc";}
The results of compiling with CL 16.XX and g++ 4.9.3 are as follows:
It is proved that VS2010 CL does not support the new features of the raw string of C + + 11. It seems that when reading the next [second Edition], I have to use the g++ 3.9.3 compiler first, because now I'm not going to upgrade VS2010 to VS2015 or any other high-level version.
4 concluding remarks
The advent of c++11 new features makes it easier for programmers to work because it incorporates many of the benefits of functional languages and blends the benefits of other languages. Of course, it also brings the increase of language learning. But it doesn't matter, it is compatible with c++98/03 and so on, if you do not want to learn c++11, completely can disregard it. It has the advantage of more convenient programming and improved program performance. The more features that correspond to the C + + language, the more you need to learn, and not all of them.
Faced with the rapid development of computing technology, we only continue to learn, good at learning, to keep up with the pace of the times, embrace and use of new technologies.
[1]: Nicolai M. Josuttis. The C + + standard Library A tutorial and Reference. 1999.
[2]: Nicolai M. Josuttis. The C + + standard Library A tutorial and Reference. 2nd edition. Upper Saddle River, NJ, Usa:addison-wesley, 2012.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
VS2010 compiler tool CL for C++11 standard support test