[Solved] Example on C++ data member aligment


For starters

Bar[5]

is not valid code. It should be something like

Bar f[5]

Furthermore, that macro doesn’t make sense. You might try this instead:

template< class T >
struct testStruct{ char x; T test; };

#define ALIGNMENT_OF(t) offsetof( testStruct< t >, test )

And finally there’s a typo:

ALIGNMENT_OF(f_B) //should be f_b

2

solved Example on C++ data member aligment