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
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
4
5
helpviewer_keywords: ["statically linking to ATL Registrar code", "linking [C++], to ATL Registrar code"]
5
6
ms.assetid: 835f5885-87a6-48fa-91e6-60988ee65538
6
7
---
7
-
# Setting Up a Static Link to the Registrar Code (C++ Only)
8
+
# Setting up a static link to the Registrar code (C++ Only)
8
9
9
10
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.
10
11
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.)
12
13
13
-
## To create a static link using DECLARE_REGISTRY_RESOURCEID
14
+
## To create a static link using `DECLARE_REGISTRY_RESOURCEID`
14
15
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).
Copy file name to clipboardExpand all lines: docs/build/importing-data-using-declspec-dllimport.md
+18-9Lines changed: 18 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,18 @@
1
1
---
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
4
5
helpviewer_keywords: ["importing data [C++]", "dllimport attribute [C++], data imports", "__declspec(dllimport) keyword [C++]", "importing DLLs [C++], __declspec(dllimport)"]
5
6
ms.assetid: 0ae70b39-87c7-4181-8be9-e786e0db60b0
6
7
---
7
-
# Importing Data Using __declspec(dllimport)
8
+
# Importing data using `__declspec(dllimport)`
8
9
9
10
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:
10
11
11
-
```
12
+
```C
12
13
// 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
14
16
ULONG ulDataInDll;
15
17
16
18
#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
20
22
21
23
You would then export the data in your .DEF file:
22
24
23
-
```
25
+
```DEF
24
26
// project.def
25
27
LIBRARY project
26
28
EXPORTS
@@ -29,7 +31,7 @@ EXPORTS
29
31
30
32
and access it outside the DLL:
31
33
32
-
```
34
+
```C
33
35
if (*ulDataInDll == 0L)
34
36
{
35
37
// Do stuff here
@@ -40,8 +42,15 @@ When you mark the data as **`__declspec(dllimport)`**, the compiler automaticall
40
42
41
43
To export the data automatically from the DLL, use this declaration:
42
44
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
Copy file name to clipboardExpand all lines: docs/build/reference/c-cpp-prop-page.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "C/C++ Project Properties (Visual Studio)"
3
3
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
5
5
ms.topic: "article"
6
6
ms.assetid: 16375038-4917-4bd0-9a2a-26343c1708b7
7
7
---
@@ -72,7 +72,7 @@ Treats compiler warnings as errors. For a new project, it may be best to use [`/
72
72
73
73
### Warning Version
74
74
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).
76
76
77
77
### Diagnostics Format
78
78
@@ -96,7 +96,7 @@ Multi-processor Compilation.
96
96
97
97
### Optimization
98
98
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).
100
100
101
101
#### Choices
102
102
@@ -127,8 +127,8 @@ Whether to favor code size or code speed; 'Global Optimization' must be turned o
127
127
128
128
#### Choices
129
129
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.)
132
132
-**Neither** - No size and speed optimization.
133
133
134
134
### Omit Frame Pointers
@@ -141,7 +141,7 @@ Enables memory space optimization when using fibers and thread local storage acc
141
141
142
142
### Whole Program Optimization
143
143
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).
145
145
146
146
## C/C++ Preprocessor Properties
147
147
@@ -171,7 +171,7 @@ Preprocess without #line directives.
171
171
172
172
### Keep Comments
173
173
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).
175
175
176
176
## C/C++ Code Generation Properties
177
177
@@ -206,7 +206,7 @@ Enable basic runtime error checks, incompatible with any optimization type other
-**Multi-threaded** - Causes your application to use the multithread, static version of the run-time library.
219
219
-**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.
222
222
223
223
### Struct Member Alignment
224
224
@@ -253,15 +253,15 @@ Guard security check helps detect attempts to dispatch to illegal block of code.
253
253
254
254
### Enable Function-Level Linking
255
255
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).
257
257
258
258
### Enable Parallel Code Generation
259
259
260
260
Allows the compiler to generate parallel code for loops identified using `#pragma loop(hint_parallel[(n)])` when optimization is enabled.
261
261
262
262
### Enable Enhanced Instruction Set
263
263
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).
265
265
266
266
#### Choices
267
267
@@ -284,11 +284,11 @@ Sets the floating point model. Sets [`/fp:precise`, `/fp:strict`, `/fp:fast`](fp
284
284
285
285
### Enable Floating Point Exceptions
286
286
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).
288
288
289
289
### Create Hotpatchable Image
290
290
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).
292
292
293
293
### Spectre Mitigation
294
294
@@ -315,19 +315,19 @@ When specified, the type **`wchar_t`** becomes a native type that maps to **`__w
315
315
316
316
### Force Conformance in For Loop Scope
317
317
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.
319
319
320
320
### Remove unreferenced code and data
321
321
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.
323
323
324
324
### Enforce type conversion rules
325
325
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.
327
327
328
328
### Enable Run-Time Type Information
329
329
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).
331
331
332
332
### Open MP Support
333
333
@@ -356,8 +356,8 @@ Enables creation or use of a precompiled header during the build. Sets [`/Yc`](y
356
356
357
357
#### Choices
358
358
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.
361
361
-**Not Using Precompiled Headers** - Not using precompiled headers.
@@ -29,14 +29,14 @@ By default, the compiler may define a large number of Microsoft-specific symbols
29
29
30
30
| Symbol | Function |
31
31
|--|--|
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. |
36
36
|`_M_IX86`| By default, defined to 600 for x86 targets. |
37
37
|`_MSC_VER`| Defined as a unique integer value for each compiler version. For more information, see [Predefined macros](../../preprocessor/predefined-macros.md). |
38
38
|`_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. |
40
40
41
41
For a complete list of Microsoft-specific predefined macros, see [Predefined macros](../../preprocessor/predefined-macros.md).
0 commit comments