I would like to define a structure (a file header, in this case) that
includes certain constants, and ensure that those members of the
structure are always initialized to the same value.
Something like
#define MY_MAGIC_NUMBER 0x12345678
typedef struct {
const unsigned long magic_number = MY_MAGIC_NUMBER ;
/* more stuff ... */
} FILE_HEADER ;
but obviously I can't put an initializer inside a typedef declaration.
What's a good way to do this? I can define a macro that does the
initialization (if I leave off the "const" qualifier on magic_number),
but then I have to depend on the programmer remembering to call the
macro with each instance of a FILE_HEADER struct. I'd rather have the
initialization done automatically.
Thanks
S. Austin