Click here to Skip to main content
12,760,992 members (28,393 online)
Click here to Skip to main content
Add your own
alternative version


48 bookmarked
Posted 5 Apr 2012

What's New in VS11 for Native Development

, 5 Apr 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
In this article I will enumerate and discuss some of the new or improved features for native development (but not all).

Visual Studio 11 Beta was made available at the end of February. Ignoring the commonly disliked chrome theme, the new version of Visual Studio provides lots of improvements, both for managed and native development. In this article I will enumerate and discuss some of the new or improved features for native development (but not all). These include improved or new features in the C++11 language support, the compiler and linker, the VC++ libraries and the IDE. A complete list of these features is available in MSDN. VS11 beta can be download from here.

No Windows XP Support

Before discussing what's new I must stress a very important point: VS11 does not support Windows XP and Windows Server 2003 anymore. Native applications built with VS11 will no longer run on WinXP/Server2003 because the VC++ libraries (CRT and MFC) use system APIs that are only available starting with Vista. The minimum supported operating systems are Windows Server 2008 SP2 and Windows Vista. An item on Microsoft Connect targets this problem.

Mike Ryan has written a blog post about getting your statically linked VS11 native application run on Windows XP, by wrapping the required missing APIs and making an assembly language forwarding directive that calls them. His tutorial is available here.

C++11 Support

VS11 extends the C++ compiler's support for C++11, but not everything is yet implemented. However, they have promised to deliver updated support to core features after the release of VS11, probably in the form of a feature pack. This blog post from the VC++ Team contains a table with the support for C++11 features in VS10 and VS11. The new features in VS11 include:

  • Forward declared enums and full support for strongly typed enum
  • Standard-layout and trivial types
  • Range-based for loops
  • Override and final
  • Concurrency features: reworded sequence points, atomics, strong compare and exchange, bidirectional fences and data-dependency ordering

Strongly typed enums

Regular C++ enumerations export their enumerators to the surrounding scope. This has two drawbacks. First, it can lead to name clashes, if two enumerators in different enums declared in the same scope have the same name; second, it's not possible to use an enumerator with a fully qualified name, including the enum name. These issues have been addressed in the new standard which provides a new kind of enums, introduced with "enum class" and called strongly-typed enums. They no longer export their enumerators to the surrounding scope, can have user specified underlying type of an integral type (also added for tranditional enums) and do not convert implicitly to int.

enum class Options {None, One, All};
Options o = Options::All;

Forward declaration of enums allows declaring enums before they are defined.

enum class Options;
void make_selection(Options* op);
// ... 
enum class Options {None, One, All};

An article on strongly typed enums can be found here.

Range-based for loops

Writing (for) loops over a range of values didn't use to be very friendly in C++. All major languages used to have a way to make this simpler, but not C++. C++11 introduces range-based for loops that have a simple syntax for iterating arrays or containers. It looks like this:

int arr[] = {1,2,3,4,5};

for(int i : arr)
  cout << i << " ";

You can even substitute the type and use the auto keyword, which is especially helpful when you work with STL containers (and you might have something like map<int, vector<string>>).

for(auto i : arr)
   cout << i << " ";

In this examples the variable 'i' is read-only. You cannot change its value. If you want to change the content you can use a reference.

for(auto &i : arr)
   i *= i;

The new range-based for loops works with arrays, strings and STL containers, but also with any user-defined data structure provided that your iterator:

  • has a begin() and end() method operating on your custom data structure
  • has an operator*, operator != and operator++ (the prefix version)

An example on how to write such an iterator can be found in this article.

Override and final

C++ didn't use to have a method to specify that a virtual method in a derived class overrides a method from the base class. In fact the virtual keyword is optional on the derived class, which makes this even more confusing. It is possible to make mistakes when writing virtual methods. Let's take for instance this example:

class B 
   virtual void f(int) {cout << "B::f" << endl;}

class D : public B
   virtual void f(float) {cout << "D::f" << endl;}

The f() method in class D does not override the method with the same name in B, because the argument is of another type. The following example is also wrong, because B::f is const, and D::f is not, therefore it's not an override.

class B 
   virtual void f(int) const {cout << "B::f " << endl;}

class D : public B
   virtual void f(int) {cout << "D::f" << endl;}

C++11 provides the possibility to specify that a method is indented to override a base virtual method. This is achieved by marking a method with 'override'. This is not a keyword, but a special identifier, and it can be used elsewhere as an identifier.

class B 
   virtual void f(int) {cout << "B::f" << endl;}

class D : public B
   virtual void f(float) override {cout << "D::f" << endl;}

The code above generates the following compiler error:

error C3668: 'D::f' : method with override specifier 'override' did not override any base class methods

On the other hand it is possible that you do not want a method to be further overridden in the hierarchy. The special identifier 'final' (not a keyword) can be used to mark a function as such. The following example generates an error.

class B 
   virtual void f(int) final {cout << "B::f" << endl;}

class D : public B
   virtual void f(int) override {cout << "D::f" << endl;}
error C3248: 'B::f': function declared as 'final' cannot be overridden by 'D::f'

Bjarne Stroustrup discusses more about override and final on his C++11 FAQ page.

C++ Compiler enhancements: auto-vectorizor and auto-parallelizer

So far the C++ compiler only used the scaler unit from the CPU. However, nowadays, all CPUs have a vector unit too (see SSE on Wikipedia). These contain vector registers that can perform operations on vectors (a sequence of numbers) in a single instruction. That means if you have a loop where data doesn't carry dependencies (like a loop that performs a summation) it could be actually executed with the vector instructions (of course given some constrains are met), making the execution time be several times smaller. The C++ compiler in VS11 has been enhanced to take advantage of the SIMD instructions and auto-vectorize the loops it finds safe. This is enabled by default and requires no changes to your code. Given the particularities of your program, it can provide a significant implicit boost.

Besides SSE support, nowadays most CPUs are also multi-core, which means multiple vector units. Therefore in addition to the auto-vectorization, the VS11 C++ compiler can also do an auto-parallelization, spreading the computation on multiple cores. The auto-parallelizer is very conservative and in the current version will find few cases where the loops can be auto-parallelized. However, developers can instruct the compiler to auto-parallelize a loop by using pragma loop(hint_parallel(N)). The auto-parallelizer is not enabled by default on VS11. You have to go to your project's properties, C/C++ > Code Generation and set "Enable Parallel Code Generation" to "Yes", or use /Qpar if you build from a command line.

Jim Radigan and Jim Hogg provide insights into the auto-vectorizor and the auto-parallelizer in this channel9 interview.

IDE enhancements

C++/CLI IntelliSense

In VS2010 the VC++ team has re-designed the IntelliSense, but VS2010 shipped without any IntelliSense support for C++/CLI projects (this VC++ Team blog post explains why). This has been a major complain and the good news is that VS11 comes with IntelliSense support for C++/CLI. That means features like Quick Info, Parameter Help, List Members and Auto Completion do work properly with C++/CLI.

C++ Code Snippets

Code snippets are small blocks of reusable code that you can insert in your code (such as a switch or a try-catch block). They have been available for a while, but not for C++. VS11 now provides C++ code snippets for switch, if-else, for loop and other constructs. In addition, developers can define their own snippets. This article by Ovidiu Cucu shows how to do that.

Semantic Colorization

I've been always annoyed by the IDE's inability to colorize C++ code. I was nicely surprised to see VS11 has finally done something about it. The new IDE is able to colorize by default types, enums, macros and other C++ tokens. More about that here.

Parallel Libraries

Microsoft delivered with Visual Studio 2010 two C++ libraries for native parallel programming, one called Parallel Patterns Library (or simply PPL) used for writing task parallelism, and a second one called Asynchronous Agents Library used for expressing dataflows and pipelining tasks using an actor-based programming model and message passing. In VS11 these libraries were extended to provide better performance, more control and richer support for the most used parallel patterns.

The PPL library becomes even more relevant with Windows 8 and WinRT that offers a new programming model in which all blocking operations are asynchronous. PPL makes it easier for developers to write C++ async code (though not as easy as in C#), where continuations, a new feature to the library, plays a key role. This Asynchronous Programming in C++ Using PPL article by Artur Laksberg addresses this topic.

VS11 introduces a new library (announced last summer) called C++ Accelerated Massive Parallelism (or simply C++ AMP). This is a native library built on top of DirectX that allows developers to write parallel code that runs on heterogeneous hardware. It aims to make GPU programming easy for C++ developers. It provides multidimensional arrays, indexing, memory transfer, tiling, and a mathematical function library, while language extensions and compiler restrictions can be used to control how data moves between the CPU and GPU. A C++ AMP "Hello world" application can be found here.

Lots of information and examples can be found on the blog of the team that implemented these libraries.

Little MFC Updates

VS11 doesn't bring any updates to MFC, except mainly for a series of bug fixes (including paint/draw issues or memory leaks) as explained by Pat Brenner in this blog post. The only significant change was reducing the size of statically-linked MFC applications that use "MFC controls". These are the controls that are part of the feature pack delivered to MFC in Visual Studio 2008 and that are prefixed with "MFC" (such as CMFCButton, CMFCListCtrl, CMFCToolbar, CMFCMenuBar, etc.). In Visual Studio 2010, statically-linked MFC applications that use such controls had a dramatic increase in size. This was fixed for VS11, though changes could not be propagated back to Visual Studio 2010 because it would have broken existing code. The solution is to define _AFX_NO_MFC_CONTROLS_IN_DIALOGS in your application if you do not use such controls. In this case, your application will be linked with a new, smaller version of the library that has the same methods, but different implementation. If at any point you need to add MFC controls, you just remove that macro without any other code changes. Of course, in this case, the application would be linked to the regular library implementation and the size would increase. This blog post provides the details of the problem and the solution.

The lack of investment in MFC is not something unexpected, given the company's push for Windows 8, WinRT and Metro style-applications. Unfortunately, this will probably be the case for all future releases. I believe MFC will no longer benefit from any enhancements other than bug fixes and maybe some header updates once in a while.

Windows 8

Windows 8 is the new flag ship of the company and VS11 provides great support for building C++ applications for the new Windows runtime, called WinRT. (This is also the reason why there are no important updates to MFC.) WinRT is still a native runtime. The applications built for WinRT are called Metro-style applications. The great part about it is that the same API is exposed to C++, C#/VB.NET and JavaScript.

Microsoft has built an extension to C++, called C++ Component eXtensions, or simply C++/CX. It is the language used to author native components or applications for WinRT. It has a very similar syntax to C++/CLI, though there are some differences, and unlike the C++/CLI which targets the CLR, C++/CX targets WinRT and native code. For more information on this topic read Nish Sivakumar's Visual C++ and WinRT/Metro - Some fundamentals.

In VS11 it is possible to:

  • build Metro-style applications in C++ using the new native XAML framework or DirectX; it is actually possible to use both of them in the same application, the two operate efficiently.
  • build WinRT components for Metro-style apps written with C++, HTML5/JabaScript or .NET.

When you install VS11 on Windows 8 you get some additional Windows Metro style templates. These are not available on the other systems, because WinRT is not available on the previous operating systems.

Here is a classic "Hello world!" C++ application using the native XAML framework for the UI. There is basically no C++ code (other than what the wizard generated for this type of project). There is a slider on the top and a block of text displaying "Hello world". The font size of the text block is bound to the value of the slider. Everything is done in XAML.


    <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
            <RowDefinition Height="15*"/>
        <Slider Name="slider" Minimum="20" Maximum="80"
                Grid.Row="0" />
        <TextBlock Text="Hello world!"
                   FontSize="{Binding ElementName=slider, Path=Value, Mode=OneWay}" 
                   Grid.Row="1" />


VS11 brings significant improvements or new features for native developers. These include new features from C++11 (although more are expected after the RTM), updates to the VC++ libraries, improvements to the VC++ compiler, new features in the IDE for C++, support for building Windows 8 Metro-style applications and others. On the other hand there are very few improvements in MFC and, very important, no support for Windows XP and Windows Server 2003. If your native applications still target these operating systems you won't be able to use the new toolset to build them.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Marius Bancila
Architect Visma Software
Romania Romania
Marius Bancila is a Microsoft MVP for VC++. He works as a system architect for Visma, a Norwegian-based company. He is mainly focused on building desktop applications with VC++ and VC#. He keeps a blog at, focused on Windows programming. He is the co-founder of, a community for Romanian C++ programmers.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Mohammad Shuvo8-Oct-15 19:28
memberMohammad Shuvo8-Oct-15 19:28 
GeneralMy vote of 5 Pin
Nish Sivakumar4-Apr-13 7:14
sitebuilderNish Sivakumar4-Apr-13 7:14 
GeneralMy vote of 5 Pin
manoj kumar choubey17-May-12 23:53
membermanoj kumar choubey17-May-12 23:53 
QuestionMy vote 5 Pin
Member 857608115-May-12 21:19
memberMember 857608115-May-12 21:19 
GeneralMy vote of 5 Pin
Aescleal15-May-12 8:09
memberAescleal15-May-12 8:09 
GeneralMy vote of 5 Pin
Mihai MOGA15-Apr-12 19:14
memberMihai MOGA15-Apr-12 19:14 
GeneralMy vote of 5 Pin
revram13-Apr-12 20:18
memberrevram13-Apr-12 20:18 
GeneralPerformance Pin
Ahmed Charfeddine13-Apr-12 0:57
memberAhmed Charfeddine13-Apr-12 0:57 
GeneralGood work Marius Pin
Espen Harlinn12-Apr-12 14:29
mvpEspen Harlinn12-Apr-12 14:29 
GeneralRe: Good work Marius Pin
Aescleal15-May-12 8:11
memberAescleal15-May-12 8:11 
QuestionNot supporting Windows XP is a problem? Pin
sevenacids12-Apr-12 4:39
membersevenacids12-Apr-12 4:39 
AnswerRe: Not supporting Windows XP is a problem? Pin
Pablo Aliskevicius15-Apr-12 4:06
memberPablo Aliskevicius15-Apr-12 4:06 
GeneralRe: Not supporting Windows XP is a problem? Pin
ed welch15-Dec-12 4:06
membered welch15-Dec-12 4:06 
GeneralRe: Not supporting Windows XP is a problem? Pin
Marius Bancila16-Dec-12 10:53
memberMarius Bancila16-Dec-12 10:53 
AnswerRe: Not supporting Windows XP is a problem? PinPopular
Marius Bancila16-Apr-12 10:51
memberMarius Bancila16-Apr-12 10:51 
GeneralRe: Not supporting Windows XP is a problem? Pin
surajfrommumbai17-Apr-12 23:38
membersurajfrommumbai17-Apr-12 23:38 
GeneralRe: Not supporting Windows XP is a problem? Pin
xComaWhitex6-May-12 11:11
memberxComaWhitex6-May-12 11:11 
GeneralMy vote of 5 Pin
Victor Nijegorodov10-Apr-12 0:20
memberVictor Nijegorodov10-Apr-12 0:20 
GeneralMy vote of 5 Pin
kanalbrummer9-Apr-12 20:19
memberkanalbrummer9-Apr-12 20:19 
GeneralMy vote of 5 Pin
Member 21198449-Apr-12 11:42
memberMember 21198449-Apr-12 11:42 
GeneralMy vote of 5 Pin
John Schroedl9-Apr-12 7:28
memberJohn Schroedl9-Apr-12 7:28 
GeneralMy vote of 5 Pin
bartolo9-Apr-12 1:29
memberbartolo9-Apr-12 1:29 
QuestionMy opinion Pin
xComaWhitex6-Apr-12 14:16
memberxComaWhitex6-Apr-12 14:16 
AnswerRe: My opinion Pin
Marius Bancila7-Apr-12 10:03
memberMarius Bancila7-Apr-12 10:03 
GeneralRe: My opinion Pin
Espen Harlinn13-Apr-12 5:38
mvpEspen Harlinn13-Apr-12 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 5 Apr 2012
Article Copyright 2012 by Marius Bancila
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid