| ... | ... | @@ -3316,10 +3316,12 @@ test "default struct initialization fields" { |
| 3316 | 3316 | {#header_close#} |
| 3317 | 3317 | |
| 3318 | 3318 | {#header_open|extern struct#} |
| 3319 | | <p>An {#syntax#}extern struct{#endsyntax#} has in-memory layout guaranteed to match the |
| 3320 | | C ABI for the target.</p> |
| 3321 | | <p>This kind of struct should only be used for compatibility with the C ABI. Every other |
| 3322 | | use case should be solved with {#link|packed struct#} or normal {#link|struct#}.</p> |
| 3319 | <p>An {#syntax#}extern struct{#endsyntax#} has in-memory layout matching |
| 3320 | the C ABI for the target.</p> |
| 3321 | <p>If well-defined in-memory layout is not required, {#link|struct#} is a better choice |
| 3322 | because it places fewer restrictions on the compiler.</p> |
| 3323 | <p>See {#link|packed struct#} for a struct that has the ABI of its backing integer, |
| 3324 | which can be useful for modeling flags.</p> |
| 3323 | 3325 | {#see_also|extern union|extern enum#} |
| 3324 | 3326 | {#header_close#} |
| 3325 | 3327 | |
| ... | ... | @@ -3338,9 +3340,6 @@ test "default struct initialization fields" { |
| 3338 | 3340 | <li>An {#link|enum#} field uses exactly the bit width of its integer tag type.</li> |
| 3339 | 3341 | <li>A {#link|packed union#} field uses exactly the bit width of the union field with |
| 3340 | 3342 | the largest bit width.</li> |
| 3341 | | <li>Non-ABI-aligned fields are packed into the smallest possible |
| 3342 | | ABI-aligned integers in accordance with the target endianness. |
| 3343 | | </li> |
| 3344 | 3343 | </ul> |
| 3345 | 3344 | <p> |
| 3346 | 3345 | This means that a {#syntax#}packed struct{#endsyntax#} can participate |