Skip to content

Commit 30af091

Browse files
committed
Further improvement
1 parent 091a595 commit 30af091

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/type-layout.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ the sake of clarity. To perform memory layout computations in actual code, use
236236

237237
</div>
238238

239-
> Note: This algorithm can produce zero-sized structs. In C, the size of
240-
> structs without data is zero. This is not the same as C++ where structs
241-
> without data still have a size of one byte.
239+
> Note: This algorithm can produce zero-sized structs. In C, an empty struct
240+
> declaration like `struct Foo { }` is illegal. However, both gcc and clang
241+
> support options to enable such structs, and assign them size zero. C++, in
242+
> contrast, gives empty structs a size of 1, unless they are inherited from or
243+
> they are fields that have the `[[no_unique_address]]` attribute, in which
244+
> case they do not increase the overall size of the struct.
242245
243246
#### \#[repr(C)] Unions
244247

0 commit comments

Comments
 (0)