File tree 1 file changed +8
-0
lines changed
reference/src/representation
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,14 @@ following:
188
188
189
189
[ ^ aligned ] : Aligning an offset O to an alignment A means to round up the offset O until it is a multiple of the alignment A.
190
190
191
+ One deviation from C comes about with "empty structs". In Rust, a
192
+ struct that contains (transitively) no data members is considered to
193
+ have size zero, which is not something that exists in C. This includes
194
+ a struct like ` #[repr(C)] struct Foo { } ` . Further, when a
195
+ ` #[repr(C)] ` struct has a field whose type has zero-size, that field
196
+ may induce padding due to its alignment, but will not otherwise affect
197
+ the offsets of subsequent fields (as it takes up zero space).
198
+
191
199
The intention is that if one has a set of C struct declarations and a
192
200
corresponding set of Rust struct declarations, all of which are tagged
193
201
with ` #[repr(C)] ` , then the layout of those structs will all be
You can’t perform that action at this time.
0 commit comments