Skip to content

Commit 0df66ef

Browse files
author
Colin Robertson
committed
Fix void main and csharp usage
1 parent 86696ac commit 0df66ef

10 files changed

Lines changed: 29 additions & 29 deletions

docs/build/reference/netmodule-files-as-linker-input.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
---
2-
title: ".netmodule Files as Linker Input"
2+
title: ".netmodule files as linker input"
33
ms.date: "05/16/2019"
4-
helpviewer_keywords: ["MSIL linking", "linking [C++], modules", ".netmodules", "modules, Visual C++"]
4+
helpviewer_keywords: ["MSIL linking", "linking [C++], modules", ".netmodule files", "modules, Visual C++"]
55
ms.assetid: a4bcbe8a-4255-451d-853b-f88cfd82f4e1
66
---
7-
# .netmodule Files as Linker Input
7+
# .netmodule files as linker input
88

9-
link.exe now accepts MSIL .obj and .netmodules as input. The output file produced by the linker is an assembly or a .netmodule with no run-time dependency on any of the .obj or .netmodules that were input to the linker.
9+
link.exe accepts MSIL .obj and .netmodule files as input. The output file produced by the linker is an assembly or a .netmodule with no run-time dependency on any of the .obj or .netmodule files that were input to the linker.
1010

11-
.netmodules are created by the MSVC compiler with [/LN (Create MSIL Module)](ln-create-msil-module.md) or by the linker with [/NOASSEMBLY (Create a MSIL Module)](noassembly-create-a-msil-module.md). .objs are always created in a Visual C++ compilation. For other Visual Studio compilers, use the **/target:module** compiler option.
11+
## Remarks
1212

13-
You must pass to the linker the .obj file from the Visual C++ compilation that created the .netmodule. Passing in a .netmodule is no longer supported because the **/clr:pure** and **/clr:safe** compiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017 and later.
13+
.netmodule files are created by the MSVC compiler with [/LN (Create MSIL Module)](ln-create-msil-module.md) or by the linker with [/NOASSEMBLY (Create a MSIL Module)](noassembly-create-a-msil-module.md). .obj files are always created in a C++ compilation. For other Visual Studio compilers, use the **/target:module** compiler option.
1414

15-
For information on how to invoke the linker from the command line, see [Linker Command-Line Syntax](linking.md), [Use the MSVC toolset from the command line](../building-on-the-command-line.md), and [Set the Path and Environment Variables for Command-Line Builds](../setting-the-path-and-environment-variables-for-command-line-builds.md).
15+
The linker must be passed the .obj file from the C++ compilation that created the .netmodule. Passing in a .netmodule is no longer supported because the **/clr:pure** and **/clr:safe** compiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017 and later.
1616

17-
Passing a .netmodule or .dll file to the linker that was compiled by the MSVC compiler with **/clr** can result in a linker error. For more information, see [Choosing the Format of .netmodule Input Files](choosing-the-format-of-netmodule-input-files.md).
17+
For information on how to invoke the linker from the command line, see [Linker command-line syntax](linking.md), [Use the MSVC toolset from the command line](../building-on-the-command-line.md), and [Set the path and environment variables for command-line builds](../setting-the-path-and-environment-variables-for-command-line-builds.md).
1818

19-
The linker accepts native .obj files as well as MSIL .obj files compiled with **/clr**. When passing mixed .objs in the same build, the verifiability of the resulting output file will, by default, be equal to the lowest level of verifiability of the input modules.
19+
Passing a .netmodule or .dll file to the linker that was compiled by the MSVC compiler with **/clr** can result in a linker error. For more information, see [Choosing the format of .netmodule input files](choosing-the-format-of-netmodule-input-files.md).
2020

21-
If you currently have an application that is composed of two or more assemblies and you want the application to be contained in one assembly, you must recompile the assemblies and then link the .objs or .netmodules to produce a single assembly.
21+
The linker accepts both native .obj files and MSIL .obj files compiled with **/clr**. You can pass mixed .obj files in the same build. The resulting output file's default verifiability is the same as the lowest input module's verifiability.
2222

23-
You must specify an entry point using [/ENTRY (Entry-Point Symbol)](entry-entry-point-symbol.md) when creating an executable image.
23+
You can change an application that's composed of two or more assemblies to be contained in one assembly. Recompile the assemblies, and then link the .obj files or .netmodule files to produce a single assembly.
2424

25-
When linking with an MSIL .obj or .netmodule file, use [/LTCG (Link-time Code Generation)](ltcg-link-time-code-generation.md), otherwise when the linker encounters the MSIL .obj or .netmodule, it will restart the link with /LTCG.
25+
Specify an entry point using [/ENTRY (Entry-point symbol)](entry-entry-point-symbol.md) when creating an executable image.
2626

27-
MSIL .obj or .netmodule files can also be passed to cl.exe.
27+
When linking with an MSIL .obj or .netmodule file, use [/LTCG (Link-time code generation)](ltcg-link-time-code-generation.md), otherwise when the linker encounters the MSIL .obj or .netmodule, it will restart the link with **/LTCG**. You'll see an informational message that the link is restarting. You can ignore this message, but to improve linker performance, explicitly specify **/LTCG**.
2828

29-
Input MSIL .obj or .netmodule files cannot have embedded resources. A resource is embedded in an output file (module or assembly) with [/ASSEMBLYRESOURCE (Embed a Managed Resource)](assemblyresource-embed-a-managed-resource.md) linker option or with the **/resource** compiler option in other Visual Studio compilers.
29+
MSIL .obj or .netmodule files can also be passed to cl.exe.
3030

31-
When performing MSIL linking, and if you do not also specify [/LTCG (Link-time Code Generation)](ltcg-link-time-code-generation.md), you will see an informational message reporting that the link is restarting. This message can be ignored, but to improve linker performance with MSIL linking, explicitly specify **/LTCG**.
31+
Input MSIL .obj or .netmodule files can't have embedded resources. Embed resources in an output module or assembly file by using the [/ASSEMBLYRESOURCE (Embed a managed resource)](assemblyresource-embed-a-managed-resource.md) linker option. Or, use the **/resource** compiler option in other Visual Studio compilers.
3232

33-
## Example
33+
## Examples
3434

35-
In C++ code the **catch** block of a corresponding **try** will be invoked for a non System exception. However, by default, the CLR wraps non-System exceptions with <xref:System.Runtime.CompilerServices.RuntimeWrappedException>. When an assembly is created from Visual C++ and non-Visual C++ modules and you want a **catch** block in C++ code to be invoked from its corresponding **try** clause when the **try** block throws a non-System exception, you must add the `[assembly:System::Runtime::CompilerServices::RuntimeCompatibility(WrapNonExceptionThrows=false)]` attribute to the source code for the non C++ modules.
35+
In C++ code, the **catch** block of a corresponding **try** will be invoked for a non-`System` exception. However, by default, the CLR wraps non-`System` exceptions with <xref:System.Runtime.CompilerServices.RuntimeWrappedException>. When an assembly is created from C++ and non-C++ modules, and you want a **catch** block in C++ code to be invoked from its corresponding **try** clause when the **try** block throws a non-`System` exception, you must add the `[assembly:System::Runtime::CompilerServices::RuntimeCompatibility(WrapNonExceptionThrows=false)]` attribute to the source code for the non-C++ modules.
3636

3737
```cpp
3838
// MSIL_linking.cpp
@@ -59,9 +59,9 @@ int main() {
5959
6060
## Example
6161
62-
By changing the Boolean value of the `WrapNonExceptionThrows` attribute, you modify the ability of the Visual C++ code to catch a non-System exception.
62+
By changing the `Boolean` value of the `WrapNonExceptionThrows` attribute, you modify the ability of the C++ code to catch a non-`System` exception.
6363
64-
```cpp
64+
```csharp
6565
// MSIL_linking_2.cs
6666
// compile with: /target:module /addmodule:MSIL_linking.obj
6767
// post-build command: link /LTCG MSIL_linking.obj MSIL_linking_2.netmodule /entry:MLinkTest.Main /out:MSIL_linking_2.exe /subsystem:console

docs/cppcx/codesnippet/CPP/cppcx_strings/class1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using namespace Strings;
88
//<snippet02>
99
using namespace Platform;
1010
String^ str = L"hello";
11-
void main(){}
11+
int main(){}
1212
//</snippet02>
1313

1414

docs/dotnet/how-to-specify-an-out-parameter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public value struct TestStruct {
3030
3131
This is a C# client that consumes the Visual C++ component created in the previous example.
3232
33-
```
33+
```csharp
3434
// cpp_out_param_2.cs
3535
// compile with: /reference:cpp_out_param.dll
3636
using System;

docs/error-messages/compiler-errors-2/compiler-error-c3390.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A generic type was instantiated incorrectly. Check the type definition. For mo
1515

1616
The first sample uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLR. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
1717

18-
```cs
18+
```csharp
1919
// C3390.cs
2020
// Compile by using: csc /target:library C3390.cs
2121
// a C# program

docs/error-messages/compiler-errors-2/compiler-error-c3391.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A generic type was instantiated incorrectly. Check the type definition. For more
1515

1616
The following sample uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
1717

18-
```cs
18+
```csharp
1919
// C3391.cs
2020
// Compile by using: csc /target:library C3391.cs
2121
// a C# program

docs/error-messages/compiler-errors-2/compiler-error-c3392.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A generic type was instantiated incorrectly. Check the type definition. For more
1515

1616
The following sample uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
1717

18-
```cs
18+
```csharp
1919
// C3392.cs
2020
// Compile by using: csc /target:library C3392.cs
2121
// a C# program

docs/extensions/consuming-generics-cpp-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This example shows a generic class defined in C#.
1717

1818
### Code
1919

20-
```cs
20+
```csharp
2121
// consuming_generics_from_other_NET_languages.cs
2222
// compile with: /target:library
2323
// a C# program

docs/extensions/identifier-cpp-cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Compiler option: `/ZW`
3434
3535
In the following example, a class named **template** is created in C# and distributed as a DLL. In the C++/CLI program that uses the **template** class, the **__identifier** keyword conceals the fact that **template** is a standard C++ keyword.
3636
37-
```cs
37+
```csharp
3838
// identifier_template.cs
3939
// compile with: /target:library
4040
public class template {
@@ -66,7 +66,7 @@ Compiler option: `/clr`
6666

6767
In the following example, a class named **template** is created in C# and distributed as a DLL. In the C++/CLI program that uses the **template** class, the **__identifier** keyword conceals the fact that **template** is a standard C++ keyword.
6868

69-
```cs
69+
```csharp
7070
// identifier_template.cs
7171
// compile with: /target:library
7272
public class template {

docs/extensions/literal-cpp-component-extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Notice the difference in the metadata for `sc` and `lit`: the `modopt` directive
8383

8484
The following sample, authored in C#, references the metadata created in the previous sample and shows the affect of **literal** and **static const** variables:
8585

86-
```cs
86+
```csharp
8787
// mcppv2_literal3.cs
8888
// compile with: /reference:mcppv2_literal2.dll
8989
// A C# program

docs/extensions/variable-argument-lists-dot-dot-dot-cpp-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The function `f` can be called from C# or Visual Basic, for example, as though i
6060
6161
In C#, an argument that is passed to a `ParamArray` parameter can be called by a variable number of arguments. The following code sample is in C#.
6262
63-
```cs
63+
```csharp
6464
// mcppv2_paramarray3.cs
6565
// compile with: /r:mcppv2_paramarray2.dll
6666
// a C# program

0 commit comments

Comments
 (0)