My intention is to output a list with offsets of all struct members from a typedef struct
.
In my case this struct is stored in an external EEPROM which can be accessed bytewise via an interface accessible via a serial connection.
To access the EEPROM contents, I need to know the offsets of the struct members.
How can I tell the compiler to perform the offsetof task on every struct member?
The C standard, and most C implementations, do not provide a way to automatically list the offsets of structure members or to iterate through structure members. You must either manually list the structure members or write your own software to parse the source code defining the structure (and to use the results of parsing to generate more code to display the offsets).