Skip to content

Commit 8895c07

Browse files
author
Colin Robertson
committed
Updated use of _DLL and UWP porting for 2411
1 parent f94b93b commit 8895c07

8 files changed

+225
-205
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
---
2-
title: "Setting Up a Static Link to the Registrar Code (C++ Only)"
3-
ms.date: "11/04/2016"
2+
title: "Setting up a static link to the Registrar code (C++ only)"
3+
description: "How to statically link C++ code to the ATL Registrar code."
4+
ms.date: 09/03/2020
45
helpviewer_keywords: ["statically linking to ATL Registrar code", "linking [C++], to ATL Registrar code"]
56
ms.assetid: 835f5885-87a6-48fa-91e6-60988ee65538
67
---
7-
# Setting Up a Static Link to the Registrar Code (C++ Only)
8+
# Setting up a static link to the Registrar code (C++ Only)
89

910
C++ clients can create a static link to the Registrar's code. Static linking of the Registrar's parser adds approximately 5K to a release build.
1011

11-
The simplest way to set up static linking assumes you have specified [DECLARE_REGISTRY_RESOURCEID](reference/registry-macros.md#declare_registry_resourceid) in your object's declaration. (This is the default specification used by the ATL.)
12+
The simplest way to set up static linking assumes you have specified [`DECLARE_REGISTRY_RESOURCEID`](reference/registry-macros.md#declare_registry_resourceid) in your object's declaration. (It's the default specification used by the ATL.)
1213

13-
## To create a static link using DECLARE_REGISTRY_RESOURCEID
14+
## To create a static link using `DECLARE_REGISTRY_RESOURCEID`
1415

15-
1. Specify [/D](../build/reference/d-preprocessor-definitions.md) **\_ATL\_STATIC\_REGISTRY** instead of **/D \_ATL\_DLL**.
16+
1. Specify **`/D _ATL_STATIC_REGISTRY`** instead of **`/D _ATL_DLL`** on the CL command line. For more information, see [`/D`](../build/reference/d-preprocessor-definitions.md).
1617

1718
1. Recompile.
1819

1920
## See also
2021

21-
[Registry Component (Registrar)](../atl/atl-registry-component-registrar.md)
22+
[Registry component (Registrar)](../atl/atl-registry-component-registrar.md)

docs/build/importing-data-using-declspec-dllimport.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
2-
title: "Importing Data Using __declspec(dllimport)"
3-
ms.date: "11/04/2016"
2+
title: "Importing data using __declspec(dllimport)"
3+
description: "How to use __declspec(dllimport) to import DLL data."
4+
ms.date: 09/03/2020
45
helpviewer_keywords: ["importing data [C++]", "dllimport attribute [C++], data imports", "__declspec(dllimport) keyword [C++]", "importing DLLs [C++], __declspec(dllimport)"]
56
ms.assetid: 0ae70b39-87c7-4181-8be9-e786e0db60b0
67
---
7-
# Importing Data Using __declspec(dllimport)
8+
# Importing data using `__declspec(dllimport)`
89

910
In the case of data, using **`__declspec(dllimport)`** is a convenience item that removes a layer of indirection. When you import data from a DLL, you still have to go through the import address table. Before **`__declspec(dllimport)`**, this meant you had to remember to do an extra level of indirection when accessing data exported from the DLL:
1011

11-
```
12+
```C
1213
// project.h
13-
#ifdef _DLL // If accessing the data from inside the DLL
14+
// Define PROJECT_EXPORTS when building your DLL
15+
#ifdef PROJECT_EXPORTS // If accessing the data from inside the DLL
1416
ULONG ulDataInDll;
1517

1618
#else // If accessing the data from outside the DLL
@@ -20,7 +22,7 @@ In the case of data, using **`__declspec(dllimport)`** is a convenience item tha
2022

2123
You would then export the data in your .DEF file:
2224

23-
```
25+
```DEF
2426
// project.def
2527
LIBRARY project
2628
EXPORTS
@@ -29,7 +31,7 @@ EXPORTS
2931

3032
and access it outside the DLL:
3133

32-
```
34+
```C
3335
if (*ulDataInDll == 0L)
3436
{
3537
// Do stuff here
@@ -40,8 +42,15 @@ When you mark the data as **`__declspec(dllimport)`**, the compiler automaticall
4042

4143
To export the data automatically from the DLL, use this declaration:
4244

43-
```
44-
__declspec(dllexport) ULONG ulDataInDLL;
45+
```C
46+
// project.h
47+
// Define PROJECT_EXPORTS when building your DLL
48+
#ifdef PROJECT_EXPORTS // If accessing the data from inside the DLL
49+
__declspec(dllexport) ULONG ulDataInDLL;
50+
51+
#else // If accessing the data from outside the DLL
52+
__declspec(dllimport) ULONG ulDataInDLL;
53+
#endif
4554
```
4655

4756
## See also

docs/build/reference/c-cpp-prop-page.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "C/C++ Project Properties (Visual Studio)"
33
description: "Reference guide to the Visual Studio Microsoft C/C++ project Property Pages properties."
4-
ms.date: 07/08/2020
4+
ms.date: 09/03/2020
55
ms.topic: "article"
66
ms.assetid: 16375038-4917-4bd0-9a2a-26343c1708b7
77
---
@@ -72,7 +72,7 @@ Treats compiler warnings as errors. For a new project, it may be best to use [`/
7272

7373
### Warning Version
7474

75-
Hide warnings introduced after a specific version of the compiler. Sets [`/Wv:xx`\[`.yy`\[`.zzzzz`\]\]](wx-treat-linker-warnings-as-errors.md).
75+
Hide warnings introduced after a specific version of the compiler. Sets [`/Wv:xx[.yy[.zzzzz]]`](wx-treat-linker-warnings-as-errors.md).
7676

7777
### Diagnostics Format
7878

@@ -96,7 +96,7 @@ Multi-processor Compilation.
9696

9797
### Optimization
9898

99-
Select option for code optimization; choose Custom to use specific optimization options. Sets [/Od](od-disable-debug.md), [/O1, /O2](o-options-optimize-code.md).
99+
Select option for code optimization; choose Custom to use specific optimization options. Sets [`/Od`](od-disable-debug.md), [`/O1`, `/O2`](o-options-optimize-code.md).
100100

101101
#### Choices
102102

@@ -127,8 +127,8 @@ Whether to favor code size or code speed; 'Global Optimization' must be turned o
127127

128128
#### Choices
129129

130-
- **Favor small code** - Favor Small Code. Minimizes the size of EXEs and DLLs by instructing the compiler to favor size over speed.
131-
- **Favor fast code** - Favor Fast Code. Maximizes the speed of EXEs and DLLs by instructing the compiler to favor speed over size. (This value is the default.)
130+
- **Favor small code** - Minimizes the size of EXEs and DLLs by instructing the compiler to favor size over speed.
131+
- **Favor fast code** - Maximizes the speed of EXEs and DLLs by instructing the compiler to favor speed over size. (This value is the default.)
132132
- **Neither** - No size and speed optimization.
133133

134134
### Omit Frame Pointers
@@ -141,7 +141,7 @@ Enables memory space optimization when using fibers and thread local storage acc
141141

142142
### Whole Program Optimization
143143

144-
Enables cross-module optimizations by delaying code generation to link time. Requires the linker option 'Link Time Code Generation'. Sets [`/GL`](gl-whole-program-optimization.md).
144+
Enables cross-module optimizations by delaying code generation to link time. Requires the linker option **Link Time Code Generation**. Sets [`/GL`](gl-whole-program-optimization.md).
145145

146146
## C/C++ Preprocessor Properties
147147

@@ -171,7 +171,7 @@ Preprocess without #line directives.
171171

172172
### Keep Comments
173173

174-
Suppresses comment strip from source code; requires that one of the 'Preprocessing' options be set. Sets [`/C`](c-preserve-comments-during-preprocessing.md).
174+
Suppresses comment strip from source code; requires setting at least one of the **Preprocessing** options. Sets [`/C`](c-preserve-comments-during-preprocessing.md).
175175

176176
## C/C++ Code Generation Properties
177177

@@ -206,7 +206,7 @@ Enable basic runtime error checks, incompatible with any optimization type other
206206

207207
- **Stack Frames** - Enables stack frame run-time error checking.
208208
- **Uninitialized variables** - Reports when a variable is used without having been initialized.
209-
- **Both (/RTC1, equiv. to /RTCsu)** - Equivalent of /RTCsu.
209+
- **Both (/RTC1, equiv. to /RTCsu)** - Equivalent of **`/RTCsu`**.
210210
- **Default** - Default runtime checks.
211211

212212
### Runtime Library
@@ -217,8 +217,8 @@ Specify runtime library for linking. Sets [`/MT`, `/MTd`, `/MD`, `/MDd`](md-mt-l
217217

218218
- **Multi-threaded** - Causes your application to use the multithread, static version of the run-time library.
219219
- **Multi-threaded Debug** - Defines _DEBUG and _MT. This option also causes the compiler to place the library name *LIBCMTD.lib* into the *`.obj`* file so that the linker will use *LIBCMTD.lib* to resolve external symbols.
220-
- **Multi-threaded DLL** - Causes your application to use the multithread- and DLL-specific version of the run-time library. Defines _MT and _DLL and causes the compiler to place the library name *MSVCRT.lib* into the *`.obj`* file.
221-
- **Multi-threaded Debug DLL** - Defines _DEBUG, _MT, and _DLL and causes your application to use the debug multithread- and DLL-specific version of the run-time library. It also causes the compiler to place the library name *MSVCRTD.lib* into the *`.obj`* file.
220+
- **Multi-threaded DLL** - Causes your application to use the multithread- and DLL-specific version of the run-time library. Defines `_MT` and `_DLL` and causes the compiler to place the library name *MSVCRT.lib* into the *`.obj`* file.
221+
- **Multi-threaded Debug DLL** - Defines `_DEBUG`, `_MT`, and `_DLL` and causes your application to use the debug multithread- and DLL-specific version of the run-time library. It also causes the compiler to place the library name *MSVCRTD.lib* into the *`.obj`* file.
222222

223223
### Struct Member Alignment
224224

@@ -253,15 +253,15 @@ Guard security check helps detect attempts to dispatch to illegal block of code.
253253

254254
### Enable Function-Level Linking
255255

256-
Allows the compiler to package individual functions in the form of packaged functions (COMDATs). Required for edit and continue to work. Sets [/Gy](gy-enable-function-level-linking.md).
256+
Allows the compiler to package individual functions in the form of packaged functions (COMDATs). Required for edit and continue to work. Sets [`/Gy`](gy-enable-function-level-linking.md).
257257

258258
### Enable Parallel Code Generation
259259

260260
Allows the compiler to generate parallel code for loops identified using `#pragma loop(hint_parallel[(n)])` when optimization is enabled.
261261

262262
### Enable Enhanced Instruction Set
263263

264-
Enable use of instructions found on processors that support enhanced instruction sets. For example, the SSE, SSE2, AVX, and AVX2 enhancements to IA-32. And, the AVX and AVX2 enhancements to x64. Currently **`/arch:SSE`** and **`/arch:SSE2`** are only available when building for the x86 architecture. If no option is specified, the compiler will use instructions found on processors that support SSE2. Use of enhanced instructions can be disabled with **`/arch:IA32`**. For more information, see [`/arch (x86)`](arch-x86.md), [`/arch (x64)`](arch-x64.md) and [`/arch (ARM)`](arch-arm.md).
264+
Enable use of instructions found on processors that support enhanced instruction sets. For example, the SSE, SSE2, AVX, and AVX2 enhancements to IA-32. And, the AVX and AVX2 enhancements to x64. Currently **`/arch:SSE`** and **`/arch:SSE2`** are only available when building for the x86 architecture. If no option is specified, the compiler will use instructions found on processors that support SSE2. Use of enhanced instructions can be disabled with **`/arch:IA32`**. For more information, see [`/arch (x86)`](arch-x86.md), [`/arch (x64)`](arch-x64.md), and [`/arch (ARM)`](arch-arm.md).
265265

266266
#### Choices
267267

@@ -284,11 +284,11 @@ Sets the floating point model. Sets [`/fp:precise`, `/fp:strict`, `/fp:fast`](fp
284284

285285
### Enable Floating Point Exceptions
286286

287-
Reliable floating-point exception model. Exceptions will be raised immediately after they're triggered. Sets [/fp:except](fp-specify-floating-point-behavior.md).
287+
Reliable floating-point exception model. Exceptions will be raised immediately after they're triggered. Sets [`/fp:except`](fp-specify-floating-point-behavior.md).
288288

289289
### Create Hotpatchable Image
290290

291-
When hotpatching is on, the compiler ensures that first instruction of each function is two bytes, as required for hot patching. Sets [/hotpatch](hotpatch-create-hotpatchable-image.md).
291+
When hotpatching is on, the compiler ensures that first instruction of each function is two bytes, as required for hot patching. Sets [`/hotpatch`](hotpatch-create-hotpatchable-image.md).
292292

293293
### Spectre Mitigation
294294

@@ -315,19 +315,19 @@ When specified, the type **`wchar_t`** becomes a native type that maps to **`__w
315315

316316
### Force Conformance in For Loop Scope
317317

318-
Used to implement standard C++ behavior for the for statement loops with Microsoft extensions. Sets [`/Za`, `/Ze` (Disable language extensions](za-ze-disable-language-extensions.md). [`/Zc:forScope`](zc-forscope-force-conformance-in-for-loop-scope.md) is on by default.
318+
Implements standard C++ behavior for the `for` statement loops with Microsoft extensions. Sets [`/Za`, `/Ze` (Disable language extensions](za-ze-disable-language-extensions.md). [`/Zc:forScope`](zc-forscope-force-conformance-in-for-loop-scope.md) is on by default.
319319

320320
### Remove unreferenced code and data
321321

322-
When specified, compiler no longer generates symbol information for unreferenced code and data.
322+
When specified, the compiler no longer generates symbol information for unreferenced code and data.
323323

324324
### Enforce type conversion rules
325325

326-
Used to identify an rvalue reference type as the result of a cast operation per the C++11 standard.
326+
Used to identify an rvalue reference type as the result of a cast operation according to the C++11 standard.
327327

328328
### Enable Run-Time Type Information
329329

330-
Adds code for checking C++ object types at run time (runtime type information). Sets [`/GR`, `/GR-`](gr-enable-run-time-type-information.md).
330+
Adds code for checking C++ object types at run time (*runtime type information*, or RTTI). Sets [`/GR`, `/GR-`](gr-enable-run-time-type-information.md).
331331

332332
### Open MP Support
333333

@@ -356,8 +356,8 @@ Enables creation or use of a precompiled header during the build. Sets [`/Yc`](y
356356

357357
#### Choices
358358

359-
- **Create** - Instructs the compiler to create a precompiled header (.pch) file that represents the state of compilation at a certain point.
360-
- **Use** - Instructs the compiler to use an existing precompiled header (.pch) file in the current compilation.
359+
- **Create** - Instructs the compiler to create a precompiled header (*`.pch`*) file that represents the state of compilation at a certain point.
360+
- **Use** - Instructs the compiler to use an existing precompiled header (*`.pch`*) file in the current compilation.
361361
- **Not Using Precompiled Headers** - Not using precompiled headers.
362362

363363
### Precompiled Header File

docs/build/reference/u-u-undefine-symbols.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "/U, /u (Undefine symbols)"
3-
ms.date: "06/08/2020"
3+
ms.date: 09/03/2020
44
f1_keywords: ["VC.Project.VCCLCompilerTool.UndefinePreprocessorDefinitions", "VC.Project.VCCLWCECompilerTool.UndefinePreprocessorDefinitions", "VC.Project.VCCLCompilerTool.UndefineAllPreprocessorDefinitions", "/u", "VC.Project.VCCLWCECompilerTool.UndefineAllPreprocessorDefinitions"]
55
helpviewer_keywords: ["-U compiler option [C++]", "Undefine Symbols compiler option", "/U compiler option [C++]", "U compiler option [C++]"]
66
ms.assetid: 7bc0474f-6d1f-419b-807d-0d8816763b2a
@@ -29,14 +29,14 @@ By default, the compiler may define a large number of Microsoft-specific symbols
2929

3030
| Symbol | Function |
3131
|--|--|
32-
| `_CHAR_UNSIGNED` | Default char type is unsigned. Defined when the [**`/J`**](j-default-char-type-is-unsigned.md) option is specified. |
33-
| `_CPPRTTI` | Defined for code compiled with the [**`/GR`**](gr-enable-run-time-type-information.md) option. |
34-
| `_CPPUNWIND` | Defined for code compiled with the [**`/EHsc`**](eh-exception-handling-model.md) option. |
35-
| `_DLL` | Defined when the [**`/MD`**](md-mt-ld-use-run-time-library.md) option is specified. |
32+
| `_CHAR_UNSIGNED` | Default char type is unsigned. Defined when the [`/J`](j-default-char-type-is-unsigned.md) option is specified. |
33+
| `_CPPRTTI` | Defined for code compiled with the [`/GR`](gr-enable-run-time-type-information.md) option. |
34+
| `_CPPUNWIND` | Defined for code compiled with the [`/EHsc`](eh-exception-handling-model.md) option. |
35+
| `_DLL` | Defined when the [`/MD`](md-mt-ld-use-run-time-library.md) option is specified. |
3636
| `_M_IX86` | By default, defined to 600 for x86 targets. |
3737
| `_MSC_VER` | Defined as a unique integer value for each compiler version. For more information, see [Predefined macros](../../preprocessor/predefined-macros.md). |
3838
| `_WIN32` | Defined for WIN32 applications. Always defined. |
39-
| `_MT` | Defined when the [**`/MD`** or **`/MT`**](md-mt-ld-use-run-time-library.md) option is specified. |
39+
| `_MT` | Defined when the [`/MD`](md-mt-ld-use-run-time-library.md) or [`/MT`](md-mt-ld-use-run-time-library.md) option is specified. |
4040

4141
For a complete list of Microsoft-specific predefined macros, see [Predefined macros](../../preprocessor/predefined-macros.md).
4242

0 commit comments

Comments
 (0)