diff options
| author | Selene ToyKeeper | 2023-11-07 08:09:10 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-11-07 08:09:10 -0700 |
| commit | e00326a6db6671414b43ee15e092c57ea976102f (patch) | |
| tree | 314608a1c7ba0d0177cab6ead8186638aa8a7e64 /fsm/tk.h | |
| parent | memes (diff) | |
| download | anduril-e00326a6db6671414b43ee15e092c57ea976102f.tar.gz anduril-e00326a6db6671414b43ee15e092c57ea976102f.tar.bz2 anduril-e00326a6db6671414b43ee15e092c57ea976102f.zip | |
made build fail if eeprom data bigger than MCU's eeprom size
Based on techniques suggested by DurvalMenezes here:
https://github.com/ToyKeeper/anduril/pull/4
Diffstat (limited to 'fsm/tk.h')
| -rw-r--r-- | fsm/tk.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -24,3 +24,17 @@ // use it like this: //#include incfile(CONFIGFILE) + +// cause a build failure if `condition` is true +// (gcc compile trick taken from an old version of include/linux/kernel.h) +// more info here: +// https://scaryreasoner.wordpress.com/2009/02/28/checking-sizeof-at-compile-time/ +#define BUILD_FAIL_IF(name, condition) \ + __attribute__((unused)) static void name() \ + { ((void)sizeof(char[1 - 2*!!(condition)])); } + +// cause a build failure if `condition` is false +#define BUILD_ASSERT(name, condition) \ + __attribute__((unused)) static void name() \ + { ((void)sizeof(char[1 - 2*!(condition)])); } + |
