Assert is a useful function that checks a condition and outputs an error if it is not met at run time. Aside from generating some overhead in the code it is also pretty useless on microcontrollers because the messages go to STDERR and, well, there isn’t one. A much better solution is to do the check at compile time as then there is no overhead and you can see the error messages.
Unfortunately the C pre-processor is just a glorified text processor and knows almost nothing about C, so you can’t use things like sizeof(). I found this solution:
// compile time static assertions (http://www.pixelbeat.org/programming/gcc/static_assert.html)
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
#define ct_assert(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
If you then write this:
ct_assert(sizeof(EEP_CONFIG_t) == 32);
If the condition is not true it will cause a divide by zero error on that line. Not ideal but it seems to work. In this case an EEPROM page happens to be 32 bytes and the struct is padded. Thanks to Pixelbeat.