I've hit a brick wall here. I'm trying to align two data structures (see their layout below) in a single pool of memory. Because the two data structures differ in size and member types, I'm trying to figure out how I should align the two. Here are the structures:-
1 2 3 4 5 6 7 8 9 10 11
struct Alpha
{
int DataA_;
char DataB_;
};
struct Bravo
{
longlong DataA_;
short DataB_;
};
...and here's the pool which I'm using (condensed):
If an "Alpha" object is placed at the first byte of the pool and a "Bravo" object is placed after the "Alpha" object, how many bytes should I need to align the two objects?
On my x64 machine, "Alpha" is 4-byte aligned and "Bravo" is 8-byte aligned. Note that these are structures used to illustrate my problem. Since I cannot possibly know the layout of each structure placed with the pool, I need some way to align the two structures. Note: I know how data-members are aligned, just not structures.