I want to extract the size of certain types from an object file / library
- without running the binary
- without special tools
- for any toolchain (GNU, MSVC, IAR)
I'd like to follow the approach presented here, but in a more generic form.
Ideally it would work like this:
// Some file.cpp
class MyClass {
// lots of members
};
#include "SizeInfo.h"
const SizeInfo<MyClass, "MyIdentifier"> info;
I would put SizeInfo anywhere I am interested in the size of a type. I might be interested in multiple types per translation unit. The solution should put the string SizeOf MyIdentifier:1234 into the resulting object file so that I can extract both identifier and size using a simple tool like grep. It is expected that the variable is thrown out of the resulting executable or a shared library because it's not used anywhere.
I am using boost in my project, so if that would simplify the implementation, I am all for it.