lundi 29 avril 2019

Size of parent and child class with same members

I'm writing some network code in C++11, and I have a doubt about the size of some packets.

Is the size of the following two structures guaranteed by the standard to be the same? even without attribute((packed)); (that I know it's non standard).

struct A
{
uint16_t a;
} __attribute__((packed));

template<class T>
struct B : A
{
T getA() { return static_cast<T>(a);}
} __attribute__((packed));

Thanks!

Aucun commentaire:

Enregistrer un commentaire