Share via


Breaking Changes in Visual C++

This document lists the breaking changes in Visual C++ 2010.

Visual C++ Compiler

  • The auto keyword has a new default meaning. Because use of the old meaning is rare, most applications will not be affected by this change.

  • The new static_assert keyword is introduced, which will cause a name conflict if there is already an identifier by that name in your code.

  • Support for the new lambda notation excludes support for coding an unquoted GUID in an IDL uuid attribute.

  • The .NET Framework 4 introduces the concept of corrupted state exceptions, which are exceptions that leave a process in an unrecoverable corrupted state. By default, you cannot catch a corrupted state exception, even with the /EHa compiler option that catches all other exceptions.

    To explicitly catch a corrupted state exception, use __try-__except statements. Or, apply the [HandledProcessCorruptedStateExceptions] attribute to enable a function to catch corrupted state exceptions.

    This change affects primarily system programmers who might have to catch a corrupted state exception. The eight exceptions are STATUS_ACCESS_VIOLATION, STATUS_STACK_OVERFLOW, EXCEPTION_ILLEGAL_INSTRUCTION, EXCEPTION_IN_PAGE_ERROR, EXCEPTION_INVALID_DISPOSITION, EXCEPTION_NONCONTINUABLE_EXCEPTION, EXCEPTION_PRIV_INSTRUCTION, STATUS_UNWIND_CONSOLIDATE. For more information about these exceptions, see the GetExceptionCode macro.

  • The revised /GS compiler option guards against buffer overruns more comprehensively than in earlier versions. This version might insert additional security checks in the stack that might decrease performance. Use the new __declspec(safebuffers) keyword to instruct the compiler to not insert security checks for a particular function.

  • If you compile with both the /GL (Whole Program Optimization) and /clr (Common Language Runtime Compilation) compiler options, the /GL option is ignored. This change was made because the combination of compiler options provided little benefit. As a result of this change, the performance of the build is improved.

  • By default, support for trigraphs is disabled in Visual C++ 2010 . 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 a corresponding punctuation character. For example, the compiler replaces the "??=" trigraph with the '#' character. Use trigraphs in C source files that use a character set that does not contain convenient graphic representations for some punctuation characters.

  • The linker no longer supports optimizing for Windows 98. The /OPT (Optimizations) option produces a compile time error if you specify /OPT:WIN98 or /OPT:NOWIN98.

  • The default compiler options that are specified by the RuntimeLibrary and DebugInformationFormat build system properties have been changed. By default, these build properties are specified in projects that are created by Visual C++ releases 7.0 through 10.0. If you migrate a project that was created by Visual C++ 6.0, consider whether to specify a value for these properties.

    In Visual C++ 2010, RuntimeLibrary = MultiThreaded (/MD) and DebugInformationFormat = ProgramDatabase (/Zi). In Visual C++ 9.0, RuntimeLibrary = MultiThreaded (/MT) and DebugInformationFormat = Disabled.

Common Language Runtime (CLR)

  • The Microsoft C# and Visual Basic compilers can now produce a no primary interop assembly (no-PIA). A no-PIA assembly can use COM types without the deployment of the relevant primary interop assembly (PIA). When consuming no-PIA assemblies produced by Visual C# or Visual Basic, you must reference the PIA assembly on the compile command before you reference any no-PIA assembly that uses the library.

Visual C++ Projects and MSBuild

  • Visual C++ projects are now based on the MSBuild tool. Consequently, project files use a new XML file format and a .vcxproj file suffix. Visual C++ 2010 automatically converts project files from earlier versions of Visual Studio to the new file format.

    An existing project is affected if it depends on the previous build tool, VCBUILD.exe, or project file suffix, .vcproj.

  • In earlier releases, Visual C++ supported the late evaluationof property sheets. For example, a parent property sheet could import a child property sheet, and the parent could use a variable defined in the child to define other variables. Late evaluation enabled the parent to use the child variable even before the child property sheet was imported. In Visual C++ 2010, a project sheet variable cannot be used before it is defined because MSBuild supports only early evaluation.

Integrated Development Environment

  • The application termination dialog box no longer ends an application.

    In previous releases, when the abort() or terminate() function closed the retail build of an application, the C Run-Time Library displayed an application termination message in a console window or dialog box. The message said in part, "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information."

    The application termination message was redundant because Windows subsequently displayed the current termination handler, which was usually the Windows Error Reporting (Dr. Watson) dialog box or the Visual Studio debugger. Starting in Visual Studio 2010, the C Run-Time Library does not display the message. Furthermore, the runtime prevents the application from ending before a debugger starts.

    This is a breaking change only if you depend on the previous behavior of the application termination message.

  • Specifically for Visual Studio 2010, IntelliSense does not work for C++/CLI code or attributes, Find All References does not work for local variables, and Code Model does not retrieve type names from imported assemblies or resolve types to their fully qualified names.

Visual C++ Libraries

  • The SafeInt class is included in Visual C++ and is no longer in a separate download. This is a breaking change only if you have developed a class that is also named "SafeInt."

  • The libraries deployment model no longer uses manifests to find a particular version of a dynamic link library. Instead, the name of each dynamic link library contains its version number, and you use that name to locate the library. For more information, see Deployment in Visual C++ 2010.

  • In previous versions of Visual Studio, you could rebuild the run time libraries. Visual C++ 2010 no longer supports building your own copies of the C run time library files.

Standard Template Library

  • The <iterator> header is no longer included automatically by many other header files. Instead, include that header explicitly if you require support for the standalone iterators defined in the <interator> header.

  • In the <algorithm> header, the checked_* and unchecked_* functions are removed. And in the <iterator> header, the checked_iterator class is removed, and the unchecked_array_iterator class has been added.

  • The CComPtr::CComPtr(int) constructor is removed. That constructor allowed a CComPtr object to be constructed from the NULL macro, but was unnecessary and allowed nonsensical constructions from non-zero integers.

    A CComPtr can still be constructed from NULL, which is defined as 0, but will fail if constructed from an integer other than literal 0. You are most likely to encounter this problem in the situation described by the following pseudo-code.

    pair<X, CComPtr<T>> myVar;
    myVar = make_pair(x, NULL);
    

    To fix the second statement, use the nullptr keyword instead of the NULL macro.

    myVar = make_pair(x, nullptr)
    
  • The following ctype member functions were removed: ctype::_Do_narrow_s, ctype::_Do_widen_s, ctype::_narrow_s, ctype::_widen_s. If an application uses one of these member functions, you must replace it with the corresponding non-secure version: ctype::do_narrow, ctype::do_widen, ctype::narrow, ctype::widen.

CRT, MFC, and ATL Libraries

  • Support has been removed for users to build the CRT, MFC, and ATL libraries. For example, an appropriate nmake file is not provided. However, users still have access to the source code for these libraries. And a document that describes the MSBuild options that Microsoft uses to build these libraries will probably be posted in a Visual C++ Team Blog.

  • MFC support for IA64 has been removed. However, support for the CRT and ATL on IA64 is still provided.

  • Ordinals are no longer reused in MFC module-definition (.def) files. This change means ordinals will not be different between minor versions, and binary compatibility for service packs and quick fix engineering releases will be improved.

  • A new virtual function was added to the CDocTemplate class. This new virtual function is CDocTemplate::OpenDocumentFile. The previous version of OpenDocumentFile had two parameters. The new version has three parameters. To support the restart manager, any class derived from CDocTemplate must implement the version that has three parameters. For more information about the function, see CDocTemplate::OpenDocumentFile. The new parameter is bAddToMRU.

Macros and Environment Variables

  • The environment variable __MSVCRT_HEAP_SELECT is no longer supported. This environment variable is removed and there is no replacement.

Microsoft Macro Assembler Reference

See Also

Other Resources

Getting Started with Visual C++ 2010