How might you go about determining the alignment of a struct at runtime? I need to be able to read (at runtime) a struct definition, fill it with data, write it to a disk file - then in another program that has the structure actually defined at compile time, read the data from the disk file and populate the struct.
In the program with the struct defined at compile time, alignment will be taken care of by the compiler. On the side where I need to allow for a dynamic definition (either interactively or via reading the struct from a given config file related to the app), how do I write the data in the same way in which it will be aligned in the other program?
Is my description clear? It's harder than I thought to explain. ;-)