mardi 30 juin 2020

Force a C++ class to have aligned attributes

Consider this class:

class C3
{
public:
    uint16_t p1;
    uint16_t p2;
    uint8_t p3;
};

sizeof(C3) is 6. Is there any compiler routine to bypass alignment and force it's size to be 5? I tried to use alignas without success...

Aucun commentaire:

Enregistrer un commentaire