You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c243063
Browse filesBrowse the repository at this point in the historyBrowse files
Colin Robertson
authored
Clean up Managed Extensions links and examples (MicrosoftDocs#81)
Copy file name to clipboardExpand all lines: docs/build/reference/doc-process-documentation-comments-c-cpp.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,8 +57,6 @@ Causes the compiler to process documentation comments in source code files and t
57
57
58
58
You can add documentation comments to your source code files. For more information, see [Recommended Tags for Documentation Comments](../../ide/recommended-tags-for-documentation-comments-visual-cpp.md).
59
59
60
-
**/doc** is not compatible with **/clr:oldSyntax**. See [/clr (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) for more information.
61
-
62
60
To use the generated .xml file with IntelliSense, make the file name of the .xml file the same as the assembly that you want to support and put the .xml file is in the same directory as the assembly. When the assembly is referenced in the Visual Studio project, the .xml file is also found. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense) and [Supplying XML Code Comments](/visualstudio/ide/supplying-xml-code-comments).
63
61
64
62
### To set this compiler option in the Visual Studio development environment
Copy file name to clipboardExpand all lines: docs/cpp/clrcall.md
-9Lines changed: 0 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,15 +54,6 @@ translation.priority.ht:
54
54
55
55
`__clrcall` function pointers are only meant to be used in the application domain in which they were created. Instead of passing `__clrcall` function pointers across application domains, use <xref:System.CrossAppDomainDelegate>. For more information, see [Application Domains and Visual C++](../dotnet/application-domains-and-visual-cpp.md).
56
56
57
-
## Example
58
-
59
-
```
60
-
// clrcall.cpp
61
-
// compile with: /clr:oldSyntax /LD
62
-
void __clrcall Test1( ) {}
63
-
void (__clrcall *fpTest1)( ) = &Test1;
64
-
```
65
-
66
57
## Example
67
58
Note that when a function is declared with `__clrcall`, code will be generated when needed; for example, when function is called.
Copy file name to clipboardExpand all lines: docs/cpp/destructors-cpp.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ translation.priority.ht:
40
40
# Destructors (C++)
41
41
"Destructor" functions are the inverse of constructor functions. They are called when objects are destroyed (deallocated). Designate a function as a class's destructor by preceding the class name with a tilde (`~`). For example, the destructor for class `String` is declared: `~String()`.
42
42
43
-
In a /clr compilation, the destructor has a special role in releasing managed and unmanaged resources. See [Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md) for more information.
43
+
In a /clr compilation, the destructor has a special role in releasing managed and unmanaged resources. See [Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers) for more information.
44
44
45
45
The destructor is commonly used to "clean up" when an object is no longer necessary. Consider the following declaration of a `String` class:
Copy file name to clipboardExpand all lines: docs/cpp/event.md
-32Lines changed: 0 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,38 +146,6 @@ public:
146
146
};
147
147
```
148
148
149
-
## Example: Managed Events
150
-
151
-
```
152
-
// EventHandling_Managed_Event.cpp
153
-
// compile with: /clr:oldSyntax /c
154
-
using namespace System;
155
-
[event_source(managed)]
156
-
public __gc class CPSource {
157
-
158
-
public:
159
-
__event void MyEvent(Int16 nValue);
160
-
};
161
-
```
162
-
163
-
When applying an attribute to an event, you can specify that the attribute apply to either the generated methods or to the Invoke method of the generated delegate. The default (`event:`) is to apply the attribute to the event.
Copy file name to clipboardExpand all lines: docs/cpp/thiscall.md
-11Lines changed: 0 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,17 +54,6 @@ translation.priority.mt:
54
54
55
55
For non-static class functions, if the function is defined out-of-line, the calling convention modifier does not have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition.
[Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md)
211
+
[Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers)
Copy file name to clipboardExpand all lines: docs/dotnet/cpp-stack-semantics-for-reference-types.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ Prior to Visual C++ 2005, an instance of a reference type could only be created
46
46
47
47
The compiler will not generate a default assignment operator for a reference type. An assignment operator allows you to create an object using stack semantics and initialize it with an existing object created using stack semantics. An assignment operator for a reference type has a signature of the following form: `void operator=( R% ){}`.
48
48
49
-
If your type's destructor releases critical resources and you use stack semantics for reference types, you do not need to explicitly call the destructor (or call `delete`). For more information on destructors in reference types, see [Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md).
49
+
If your type's destructor releases critical resources and you use stack semantics for reference types, you do not need to explicitly call the destructor (or call `delete`). For more information on destructors in reference types, see [Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers).
50
50
51
51
A compiler-generated assignment operator will follow the usual standard C++ rules with the following additions:
In standard C++, a function in a base class is hidden by a function that has the same name in a derived class, even if the derived-class function does not have the same number or kind of parameters. This is referred to as *hide-by-name* semantics. In a reference type, a function in a base class can only be hidden by a function in a derived class if both the name and the parameter list are the same. This is known as *hide-by-signature* semantics.
574
574
575
-
A class is considered a hide-by-signature class when all of its functions are marked in the metadata as `hidebysig`. By default, all classes that are created under **/clr** have `hidebysig` functions. However, a class that's compiled by using **/clr:oldSyntax** does not have `hidebysig` functions; instead, they are hide-by-name functions. When a class has `hidebysig` functions, the compiler doesn't hide functions by name in any direct base classes, but if the compiler encounters a hide-by-name class in an inheritance chain, it continues that hide-by-name behavior.
575
+
A class is considered a hide-by-signature class when all of its functions are marked in the metadata as `hidebysig`. By default, all classes that are created under **/clr** have `hidebysig` functions. When a class has `hidebysig` functions, the compiler doesn't hide functions by name in any direct base classes, but if the compiler encounters a hide-by-name class in an inheritance chain, it continues that hide-by-name behavior.
576
576
577
577
Under hide-by-signature semantics, when a function is called on an object, the compiler identifies the most derived class that contains a function that could satisfy the function call. If there is only one function in the class that could satisfy the call, the compiler calls that function. If there is more than one function in the class that could satisfy the call, the compiler uses overload resolution rules to determine which function to call. For more information about overload rules, see [Function Overloading](../cpp/function-overloading.md).
578
578
@@ -677,48 +677,6 @@ int main() {
677
677
```Output
678
678
Derived::Test4
679
679
97
680
-
```
681
-
682
-
The following sample defines a component that's compiled by using **/clr:oldSyntax**. Classes that are defined by using Managed Extensions for C++ have hide-by-name member functions.
683
-
684
-
```
685
-
686
-
// compile with: /clr:oldSyntax /LD
687
-
using namespace System;
688
-
public __gc struct Base0 {
689
-
void Test() {
690
-
Console::WriteLine("in Base0::Test");
691
-
}
692
-
};
693
-
694
-
public __gc struct Base1 : public Base0 {
695
-
void Test(int i) {
696
-
Console::WriteLine("in Base1::Test");
697
-
}
698
-
};
699
-
```
700
-
701
-
The next sample consumes the component that's built in the previous sample. Notice how hide-by-signature functionality is not applied to base classes of types that are compiled by using **/clr:oldSyntax**.
Copy file name to clipboardExpand all lines: docs/dotnet/how-to-migrate-to-clr.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ This topic discusses issues that arise when compiling native code with **/clr**
65
65
Projects previous built with Visual C++ 2003 should also first be compiled without **/clr** as Visual Studio now has increased ANSI/ISO compliance and some breaking changes. The change that is likely to require the most attention is [Security Features in the CRT](../c-runtime-library/security-features-in-the-crt.md). Code that uses the CRT is very likely to produce deprecation warnings. These warnings can be suppressed, but migrating to the new [Security-Enhanced Versions of CRT Functions](../c-runtime-library/security-enhanced-versions-of-crt-functions.md) is preferred, as they provide better security and may reveal security issues in your code.
66
66
67
67
### Upgrading from Managed Extensions for C++
68
-
Projects built with Visual C++ .NET or Visual C++ 2003 that used Managed Extensions for C++ will require at least one change to project settings, as these extensions are now deprecated. As a result, code written with Managed Extensions for C++ won't compile under **/clr**. Use **/clr:oldSyntax** instead.
68
+
Projects built with Visual C++ .NET or Visual C++ 2003 that used Managed Extensions for C++ must be rewritten to use the new syntax, as these extensions are no longer supported. Code written with Managed Extensions for C++ won't compile under **/clr**.
69
69
70
70
## Convert C Code to C++
71
71
Although Visual Studio will compile C files, it is necessary to convert them to C++ for a **/clr** compilation. The actual filename doesn't have to be changed; you can use **/Tp** (see [/Tc, /Tp, /TC, /TP (Specify Source File Type)](../build/reference/tc-tp-tc-tp-specify-source-file-type.md).) Note that although C++ source code files are required for **/clr**, it is not necessary to re-factor your code to use object-oriented paradigms.
0 commit comments