Pragmas, Compiler, and Linker Features (4)

October 30, 2009

After specifying which assemblies your code will access, you have to specify which namespaces within those assemblies you plan on using. This is accomplished with the using keyword. Without these declarations, anything you use from an included assembly must be fully referenced with the namespace. For example, if you use the MyComponents.DLL assembly, which includes [...]

0

Pragmas, Compiler, and Linker Features (3)

October 27, 2009

This code is now replaced with the #pragma once statement, as shown in the following code segment:
#pragma once
// The include file contents
Including External Assemblies for Use
Writing managed C++ code for the .NET Framework requires you to use other assemblies (usually DLLs) in order to provide the basic features of the .NET Framework. It is also [...]

0

Pragmas, Compiler, and Linker Features (2)

October 24, 2009

Listing 2.1 Use of #pragma managed and #pragma unmanaged Within Visual C++ .NET
1: // must be compiled with /clr compiler option
2:
3: // for managed code
4: #using
5:
6: // for use with the unmanaged code
7: #include
8:
9: //Managed code by default
10: void ManagedFunction(void)
11: {
12: [...]

0

Pragmas, Compiler, and Linker Features (1)

October 21, 2009

There are some other miscellaneous keywords and features added to the VC++ .NET compiler and linker that make writing code for the .NET Framework possible. These features include new pragma keywords, preprocessor directives, and compiler and linker flags.
Using New Pragmas
Two pragma statements make it possible to write new .NET applications that utilize existing legacy code. [...]

0

Creating User-Defined Attributes

October 18, 2009

Attributes provide several uses and advantages that you will learn about in a later hour’s lesson. Visual C++ .NET provides the ability to not only use the predefined attributes, but also to create your own.
Using the attribute keyword, you can create your own attributes to use within your applications. The following code segment shows how [...]

0

Using the New Language Keywords (4)

October 15, 2009

Of the new keywords, the __gc keyword is probably the most noteworthy. By declaring a type with the __gc keyword, you activate the .NET Framework functionality, such as interoperability and garbage collection, for that type. The following code example shows how a class is declared with the __gc keyword:
__gc class MyClass
{
private:
int m_nValue;
public:
[...]

0

Using the New Language Keywords (3)

October 12, 2009

__interface Declares an interface.
__nogc Declares a native C++ class that is not garbage-collected and is allocated on the standard C++ heap. This keyword is not required because the compiler defaults to __nogc if __gc is not specified.
__pin Prevents an object of a managed class from being moved in memory by the CLR [...]

0

Using the New Language Keywords (2)

October 9, 2009

Table 2.1. New Keywords for the .NET Framework in VC++ .NET.
Keyword Description
__abstract Declares an abstract class that cannot be instantiated directly. It must first be derived from, and the new class must provide implementations for any pure virtual methods.
__box Creates a copy of a __value class on the CLR heap.
__delegate Declares [...]

0

Using the New Language Keywords (1)

October 6, 2009

Several new keywords has been added to the Visual C++ .NET compiler so that it can build .NET Framework applications. The reason for some of these additions is to maintain cross-language interoperability (CLI), a standard that Microsoft defined in order for applications written in separate programming languages to easily and transparently coexist with each other [...]

0

Hour 2. Special Features of Visual C++ .NET

October 3, 2009

With such a large change in the way Visual C++ applications are written within Visual Studio .NET, it should come as no surprise that Microsoft has added several language features to accommodate writing applications for the .NET framework while still maintaining the ability to create older Visual C++ application types. Through the addition of new [...]

0