Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,13 @@ typedef struct {
uint16_t periodic : 1; /* offset 6 bit 0 */
} mytimer_t;

/* Preprocessor check of timer register layout byte count. */
#if (sizeof(mytimer_t) != 8)
#error mytimer_t struct size incorrect (expected 8 bytes)
#endif
_Static_assert(sizeof(mytimer_t) == 8,
"mytimer_t struct size incorrect (expected 8 bytes)");
```

To enhance portability, use standard-defined types (e.g., `uint16_t`, `uint32_t`) and avoid relying on compiler-specific behavior.
Where precise control over memory layout is required, such as in embedded systems or when interfacing with hardware,
always verify the structure size and layout using static assertions or preprocessor checks.
always verify the structure size and layout using static assertions.

#### Avoid extreme portability

Expand Down
12 changes: 12 additions & 0 deletions scripts/aspell-pws
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,15 @@ riscv
info
cpu
libvirt
preprocessor
sizeof
alignas
alignof
constexpr
enum
char
nullptr
typedef
BitInt
noreturn
pragma