I need a way in a C preprocessor #if to test if a value will create a 0-size array
58
4
I have a structure that must pad out to 64K to fit perfectly in an embedded project, so that it fills out a flash block. So there is a #define that adds up the elements in the structure using sizeof() and determines how big the pad[] at the end needs to be to cause the total size to be 64K. For example, #define SIZE_OF_MY_PAD (0x10000 - (sizeof(uint16_t) + sizeof(uint8_t)*32 + ... )) typedef struct { uint16_t firstElement; uint8_t secondElementArray[32]; ... uint8_t pad[SIZE_OF_MY_PAD]; }; This has worked great for a long time until suddenly we don't need the pad at all in certain build configurations because it is already exactly 64k. This causes the code to fail because our compiler (not GCC) does not allow pad[0]. I have tried various ways to...