Skip to content

Commit 9cf7f12

Browse files
authoredFeb 27, 2025··
Merge pull request #212 from sysprog21/refine-guideline
Refine guideline
2 parents 53aa839 + da37e9e commit 9cf7f12

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎CONTRIBUTING.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,15 +766,13 @@ typedef struct {
766766
uint16_t periodic : 1; /* offset 6 bit 0 */
767767
} mytimer_t;
768768
769-
/* Preprocessor check of timer register layout byte count. */
770-
#if (sizeof(mytimer_t) != 8)
771-
#error mytimer_t struct size incorrect (expected 8 bytes)
772-
#endif
769+
_Static_assert(sizeof(mytimer_t) == 8,
770+
"mytimer_t struct size incorrect (expected 8 bytes)");
773771
```
774772
775773
To enhance portability, use standard-defined types (e.g., `uint16_t`, `uint32_t`) and avoid relying on compiler-specific behavior.
776774
Where precise control over memory layout is required, such as in embedded systems or when interfacing with hardware,
777-
always verify the structure size and layout using static assertions or preprocessor checks.
775+
always verify the structure size and layout using static assertions.
778776
779777
#### Avoid extreme portability
780778

‎scripts/aspell-pws

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,15 @@ riscv
338338
info
339339
cpu
340340
libvirt
341+
preprocessor
342+
sizeof
343+
alignas
344+
alignof
345+
constexpr
346+
enum
347+
char
348+
nullptr
349+
typedef
350+
BitInt
351+
noreturn
352+
pragma

0 commit comments

Comments
 (0)
Please sign in to comment.