From 7b0cc2c80e5fe3a9a6f9515f7932e75c0d1c89bd Mon Sep 17 00:00:00 2001 From: Gerwin Klein Date: Wed, 18 Oct 2023 11:52:29 +1100 Subject: [PATCH] style: packed structs (#202) style: packed structs Explain that structs must be packed (not contain any implicit padding). Signed-off-by: Gerwin Klein --- processes/style-guide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/processes/style-guide.md b/processes/style-guide.md index dec7cf3277..555e52046a 100644 --- a/processes/style-guide.md +++ b/processes/style-guide.md @@ -248,6 +248,10 @@ anything in the general guide. * Do not use `typedef` to create a type alias for an `enum`; always specify `enum` types as `word_t` (otherwise, the `enum` size is determined by the compiler). +* All `struct` definitions must be packed, i.e. not contain any implicit padding + that is inserted by the compiler (otherwise memory content is + unspecified). Use explicit `padding` fields of the required type size to + remove implicit compiler padding. ## Further resources