Visual Studio 11 Development Guide (14) C ++ 11-c ++/CX Design

Source: Internet
Author: User

Visual Studio 11 introduced some in-depth new language extensions, officially known as C ++/CX, to support the new API Model in Windows 8. Most people will be familiar with C ++/CLI (that is, we provide language extensions for CLR), and the syntax should not seem very different.

Note that, however, the C ++/CX syntax is very similar to C ++/CLI, and the underlying implementation is very different. It does not use CLR or garbage collector, generate full local code with it.

There are many innovations in Microsoft's support for Windows 8 design, including the library-only approach and various methods integrated in languages. We have a long history of supporting COM in the Visual C ++ team. From MFC in ATL # import, in the extension for CLR including original hosting, C ++/CLI and ijw support compiling the local code into msil.

But it is not called WRL (Windows Runtime Library), and supports the development of a new C ++ template library for Windows 8 without language extension for Windows 8. WRL is quite good. It can take a look and see how all the low-level details implement lighting. It is used by many internal windows teams, although it won't suffer many of the same problems, ATL supports COM classic.
1. Creating components is still very difficult. You need to know many low-level rules related to interfaces.
2. A separate tool (midl) is required for the author interface/type.
3. Is there a way to automatically create a map interface in the lower-level to higher-level (modern) form, causing exceptions and having real return values.
4. There is no unified creation and consumption mode.

With some new concepts in the Windows Runtime Library, these disadvantages become more difficult than in the classic COM/ATL. the interface inheritance is not based on vtable. com, class inheritance is aggregated based on a similar mechanism, but there are some differences, including support for private and protected interfaces. Although there is a need for a low-level tool, such as WRL for the vast majority of purposes, but it is too difficult to use, we can do a lot better while still retaining performance, and provide a lot of control.

# The import function cannot provide a good mechanism in vc6 to consume COM objects with type libraries. Similar to the Windows Runtime Library (which uses a new. winmd file), but it provides a good consumption experience and does not create. Because the callback of asynchronous creation of many Windows Mobile models is very important and does not include at least many consumption situations of creation. In addition, creation is important for writing applications and user-defined controls for each page of the user interface is derived from the existing runtime class.

The Microsoft team has long decided that classes and interfaces should be exposed at a higher level than what abi defines. It is natural to support modern c ++ functions, such as exceptions that are considered important, and to map runtime definitions of inheritance (both interfaces and classes) to C ++.

Get the pointer of the winrt class or interface. This is also how the interface judges the difference between a low-level version and the High-Level version of the interface. There are many different suggestions, including using only *, using * With modifiers, and using various other characters such. In fact, the * modifier (_ GC) is not used in the original extension as the managed code ).

Many people already have C ++/CLI Syntax. The reference count is a form of garbage collection, which uses ^ to indicate that the "refcounted" pointer works well in ZW. Unreference ^'s return rate %, also like C ++/CLI. Although many concepts share the same approach, we decided to deviate from C ++/CLI in several fields. For example, in C ++/CX, the default Interface Class specifies that C ++/CLI is the attribute of the class itself when the interface list of the attribute is passed.

In C ++/CX, there is a better development mode than in C ++ for the CLI Reference Type and general type for interoperability. In C ++/CLI, the hosted object can be moved left and right when running in memory, and the garbage collector. This means that you cannot get the real Member Address (not fixed) or even embed the primitive type (such as INT) in addition to your class. You cannot add ^ to the local class or structure. In C ++/CX, objects cannot be moved in the memory, so all these restrictions are lost. You can put any type into the ref class. You can place ^ in any position. This mode is based on the normal c ++ type and makes programmers more flexible in C ++/Cx.

 

 

Download vs11 now

Http://www.microsoft.com/click/services/Redirect2.ashx? Cr_cc = 200098144

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.