Is there a mechanism available in most "common" C/C++ compilers (for gcc/g++, compilers for common smart phones, Visual C++, etc...) to retrieve or generate data structure alignment information? (Note that this term encompasses alignment, padding, and arrangement.) I am looking to obtain this information without needing to run any C/C++ code on the target platform.
(E.g. Could such data be obtained through DWARF/DWARF2 reliably on compilers that support it?)
Update: Yes, one can use pahole with gcc. (I have to wonder if this would work with mingw32 and if so whether the '-g' flag used to output DWARF2 data modifies code generation.) Unfortunately, gcc isn't the only compiler I have to support. (Visual C++ is the most likely second candidate.)
Update 2: For Visual C++ this looks promising. I believe between Visual C++ and g++, Windows, Linux, Mac OS X, iOS, and Android NDK are covered.
Update 3: FYI, the main reason I have for obtaining such information is to avoid deserialization for high performance loading under CPU-bound conditions. If you can think of a better way of achieving this other than writing some custom tools that use data structure alignment information, please feel free to post. My vote finger is itchy.
Update 4 after a decade: A friend of mine created a C++ library using modern language features (C++20 and on) that helps with making zero-instruction serializable structures in a practically cross-platform way: https://github.com/KaylinFinke/data_serialization/tree/main. This would have solved my original need way back in the day, so I thought I'd let others know of it here.