What’s New in Visual C++ 2010
This topic introduces new and enhanced Visual C++ features in Visual Studio 2010.
Amazon: Bestsellers Electronics and Photo
Visual C++ Projects and the Build System
Visual C++ solutions and projects are now built by using MSBuild, which replaces VCBUILD.exe. MSBuild is the same flexible, extensible, XML-based build tool that is used by the other Visual Studio languages and project types. Consequently, Visual C++ project files now use an XML file format, and have the .vcxproj file name extension. Visual C++ project files from earlier versions of Visual Studio are automatically converted to the new file format. For more information, see MSBuild (Visual C++).
The VC++ Directories setting now resides in two places. Use project property pages to set per-project values for VC++ directories. Use the Property Manager and a property sheet to set global, per-configuration values for VC++ directories.
In earlier releases, you could define dependencies between projects that were stored in the solution file. When these solutions are converted to the new project file format, dependencies are converted to project-to-project references. This change can affect applications since the concepts of solution dependencies and project-to-project references are different.
Macros and Environment Variables
The new _ITERATOR_DEBUG_LEVEL macro invokes debugging support for iterators. Use this macro instead of the older _SECURE_SCL and _HAS_ITERATOR_DEBUGGING macros.
Visual C++ Libraries
Most /analyze (Enterprise Code Analysis) warnings have been removed from the CRT, MFC, and ATL libraries.
The restart manager automatically saves documents and restarts your application if it unexpectedly closes or restarts. For example, you can use the restart manager to start your application after it is closed by an automatic update. For more information about how to configure your application to use the restart manager, see How to: Add Restart Manager Support.
The CTaskDialog class can be used instead of the standard AfxMessageBox message box. The CTaskDialog class displays and gathers more information than the standard message box does.
New ATL macros
New macros were added to ATL to expand the functionality of PROP_ENTRY_TYPE and PROP_ENTRY_TYPE_EX. PROP_ENTRY_INTERFACE and PROP_ENTRY_INTERFACE_EX enable you to add a list of valid CLSID’s. PROP_ENTRY_INTERFACE_CALLBACK and PROP_ENTRY_INTERFACE_CALLBACK_EX enable you to specify a callback function to determine if a CLSID is valid.
The SafeInt Library performs safe arithmetic operations that account for integer overflow. This library also compares different kinds of integers.
Improved IntelliSense Errors
In Visual Studio 2010, the integrated development environment (IDE) better detects errors that could cause a loss of IntelliSense and displays red wavy underlines under them. In addition, the IDE reports IntelliSense errors to the Error List Window. To display the code that is causing the problem, double-click the error in the Error List Window.
#include Auto-Complete Feature
The IDE supports auto-completion for the #include keyword. When you type #include, the IDE creates a pull-down list of valid header files. If you continue by typing a file name, the IDE filters the list based on your entry. At any point, you can select on the list the file you want to include. This lets you quickly include files without knowing the exact file name.
Visual C++ Compiler and Linker
The auto keyword has a new purpose. Use the default meaning of the auto keyword to declare a variable whose type is deduced from the initialization expression in the declaration of the variable. The /Zc:auto compiler option invokes either the new or the previous meaning of the auto keyword.
The decltype operator returns the type of a specified expression. Use the decltype operator in combination with the auto keyword to declare a type that is either complex or known only to the compiler. For example, use the combination to declare a template function whose return type depends on the types of its template arguments. Or, declare a template function that calls another function, and then returns the return type of the called function.
Lambda functions have a function body but no name. Lambda functions combine the best characteristics of function pointers and function objects.
Use a lambda function by itself, as a template function parameter instead of a function object, or together with the auto keyword to declare a variable whose type is a lambda.
The rvalue reference declarator (&&) declares a reference to an rvalue. An rvalue reference lets you use move semantics and perfect forwarding to write more efficient constructors, functions, and templates.
A static_assert declaration tests a software assertion at compile time, unlike other assertion mechanisms that test at run time. If the assertion fails, the compilation fails and a specified error message is issued.
nullptr and __nullptr Keywords
The Visual C++ compiler lets you use the nullptr keyword with native code or with managed code. The nullptr keyword indicates that an object handle, interior pointer, or native pointer type does not point to an object. The compiler interprets nullptr to be managed code when you use the /clr compiler option, and native code when you do not use the /clr option.
The Microsoft-specific __nullptr keyword has the same meaning as nullptr, but it applies to native code only. If you compile native C/C++ code by using the /clr compiler option, the compiler cannot determine whether the nullptr keyword is a native or a managed term. To make your intention clear to the compiler, use the nullptr keyword to specify the managed term, and __nullptr to specify the native term.
/Zc:trigraphs Compiler Option
By default, support for trigraphs is disabled. Use the /Zc:trigraphs compiler option to enable trigraphs support.
A trigraph consists of two consecutive question marks (??) followed by a unique third character. The compiler replaces a trigraph with the corresponding punctuation character. For example, the compiler replaces the ??= trigraph with the # (number sign) character. Use trigraphs in C source files that use a character set that does not contain certain punctuation characters.
New Profile-Guided Optimization Option
PogoSafeMode is a new profile-guided optimization option that lets you specify whether to use safe mode or fast mode when you optimize your application. Safe mode is thread-safe, but it is slower than fast mode. Fast mode is the default behavior.
New Common Language Runtime (CLR) Option /clr:nostdlib
A new option is added for /clr (Common Language Runtime Compilation). If different versions of the same libraries are included, a compile error is issued. The new option lets you exclude the default CLR libraries so that your program can use a specified version.
New pragma directive detect_mistmatch
The pragma directive detect_mismatch enables you to place a tag in your files that is compared to other tags with the same name. If there are multiple values for the same name, the linker issues an error.
ATL Control Wizard
The ATL Control Wizard no longer automatically populates the ProgID field. If an ATL control does not have a ProgID, other tools may not work with it. One example of a tool that requires controls to have a ProgID is the Insert Active Control dialog box. For more information about the dialog box, see Insert ActiveX Control Dialog Box.
MFC Class Wizard
Visual Studio 2010 reintroduces the MFC Class Wizard. You can invoke the class wizard from anywhere in your solution. The wizard lets you add classes, messages, and variables without manually modifying the individual code files.
Microsoft Macro Assembler Reference
The addition of the YMMWORD data type supports the 256-bit multimedia operands that are included in the Intel Advanced Vector Extensions (AVX) instructions.