in a mixed environment I have a common .h which inlude things like #ifdef CCODE struct RALPH #endif so far so good. now this, which, of course does not work: #ifdef CCODE struct RALPH #endif #define ralphsize sizeof (RALPH) in other words, my assembler code need know the size of the structure (ralphsize) and the assembler can not handle structures in the .h anyone have a trick beyond the obvious: #define ralphsize 47 // sizeof (RALPH) make sure to change when Erik
missed toolset, now included. Erik
[IMHO, the unspecified toolset is actually fine for this question --- it doesn't really depend on any particular compiler.] There's no trick around the actual problem --- the C preprocessor has no knowledge of struct layout even when it's processing C code, much less if it's used on assembly source. But you can at least make sure that the number in #define ralphsize always matches the actual size of the struct. Just put an equivalent of
assert(ralphsize == sizeof(struct RALPH));
excellent Band-Aid Thanks Erik