I\'m looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure.
IE: given
Right, use the offsetof macro, which (at least with GNU CC) is available to both C and C++ code:
offsetof
offsetof(struct mstct, myfield2)