Skip to content

Commit 1115b14

Browse files
authored
Merge pull request MicrosoftDocs#2485 from mikeblome/mb-pragmas
Add links to C pragma page
2 parents b7474c9 + f00e896 commit 1115b14

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

docs/c-language/pragmas.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Pragmas"
3-
ms.date: "11/04/2016"
3+
ms.date: "11/11/2019"
44
helpviewer_keywords: ["pragmas, about pragmas"]
55
ms.assetid: 3ce8aced-53ee-4524-87d0-f998d6977ff5
66
---
@@ -12,11 +12,11 @@ The following [C Pragmas](../c-language/c-pragmas.md) are defined for the Micros
1212

1313
|||||
1414
|-|-|-|-|
15-
|**alloc_text**|**data_seg**|**include_alias**|`setlocale`|
16-
|**auto_inline**|**function**|**intrinsic**|**warning**|
17-
|**check_stack**|**hdrstop**|**message**||
18-
|**code_seg**|**inline_depth**|**optimize**||
19-
|**comment**|**inline_recursion**|`pack`||
15+
|[alloc_text](../preprocessor/alloc-text.md)|[data_seg](../preprocessor/data-seg.md)|[include_alias](../preprocessor/include-alias.md)|[setlocale](../preprocessor/setlocale.md)|
16+
|[auto_inline](../preprocessor/auto-inline.md)|[function](../preprocessor/function-c-cpp.md)|[intrinsic](../preprocessor/intrinsic.md)|[warning](../preprocessor/warning.md)|
17+
|[check_stack](../preprocessor/check-stack.md)|[hdrstop](../preprocessor/hdrstop.md)|[message](../preprocessor/message.md)||
18+
|[code_seg](../preprocessor/code-seg.md)|[inline_depth](../preprocessor/inline-depth.md)|[optimize](../preprocessor/optimize.md)||
19+
|[comment](../preprocessor/comment-c-cpp.md)|[inline_recursion](../preprocessor/inline-recursion.md)|[pack](../preprocessor/pack.md)||
2020

2121
## See also
2222

docs/preprocessor/pack.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "pack pragma"
3-
ms.date: "08/29/2019"
3+
ms.date: "11/11/2019"
44
f1_keywords: ["pack_CPP", "vc-pragma.pack"]
55
helpviewer_keywords: ["pragmas, pack", "pack pragma"]
66
ms.assetid: e4209cbb-5437-4b53-b3fe-ac264501d404
@@ -25,16 +25,16 @@ Specifies the packing alignment for structure, union, and class members.
2525
(Optional) Pushes the current packing alignment value on the internal compiler stack, and sets the current packing alignment value to *n*. If *n* isn't specified, the current packing alignment value is pushed.
2626

2727
**pop**\
28-
(Optional) Removes the record from the top of the internal compiler stack. If *n* isn't specified with **pop**, then the packing value associated with the resulting record on the top of the stack is the new packing alignment value. If *n* is specified, for example, `#pragma pack(pop, 16)`, *n* becomes the new packing alignment value. If you pop using an *identifier*, for example, `#pragma pack(pop, r1)`, then all records on the stack are popped until the record that has *identifier* is found. That record is popped, and the packing value associated with the resulting record on the top of the stack is the new packing alignment value. If you pop using an *identifier* that isn't found in any record on the stack, then the **pop** is ignored.
28+
(Optional) Removes the record from the top of the internal compiler stack. If *n* isn't specified with **pop**, then the packing value associated with the resulting record on the top of the stack is the new packing alignment value. If *n* is specified, for example, `#pragma pack(pop, 16)`, *n* becomes the new packing alignment value. If you pop using an *identifier*, for example, `#pragma pack(pop, r1)`, then all records on the stack are popped until the record that has *identifier* is found. That record is popped, and the packing value associated with the resulting record on the top of the stack is the new packing alignment value. If you pop using an *identifier* that isn't found in any record on the stack, then the **pop** is ignored.
29+
30+
The statement `#pragma pack (pop, r1, 2)` is equivalent to `#pragma pack (pop, r1)` followed by `#pragma pack(2)`.
2931

3032
*identifier*\
3133
(Optional) When used with **push**, assigns a name to the record on the internal compiler stack. When used with **pop**, pops records off the internal stack until *identifier* is removed. If *identifier* isn't found on the internal stack, nothing is popped.
3234

3335
*n*\
3436
(Optional) Specifies the value, in bytes, to be used for packing. If the compiler option [/Zp](../build/reference/zp-struct-member-alignment.md) isn't set for the module, the default value for *n* is 8. Valid values are 1, 2, 4, 8, and 16. The alignment of a member is on a boundary that's either a multiple of *n*, or a multiple of the size of the member, whichever is smaller.
3537

36-
`#pragma pack(pop, identifier, n)` is undefined.
37-
3838
## Remarks
3939

4040
To *pack* a class is to place its members directly after each other in memory. It can mean that some or all members can be aligned on a boundary smaller than the default alignment of the target architecture. **pack** gives control at the data-declaration level. It differs from compiler option [/Zp](../build/reference/zp-struct-member-alignment.md), which only provides module-level control. **pack** takes effect at the first **struct**, **union**, or **class** declaration after the pragma is seen. **pack** has no effect on definitions. Calling **pack** with no arguments sets *n* to the value set in the compiler option `/Zp`. If the compiler option isn't set, the default value is 8.
@@ -103,6 +103,9 @@ The following sample shows how to use the *push*, *pop*, and *show* syntax.
103103
#pragma pack(show) // C4810
104104
#pragma pack(push, r1, 16) // n = 16, pushed to stack
105105
#pragma pack(show) // C4810
106+
107+
// pop to the identifier and then set
108+
// the value of the current packing alignment:
106109
#pragma pack(pop, r1, 2) // n = 2 , stack popped
107110
#pragma pack(show) // C4810
108111
```

0 commit comments

Comments
 (0)