From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien.Wailliez@alcatel.be To: gcc-help@gcc.gnu.org Subject: Pragma question Date: Tue, 20 Feb 2001 07:57:00 -0000 Message-id: X-SW-Source: 2001-02/msg00171.html Hello, Where can I find a precise description of the semantics of 'pragma pack' in GCC 2.95.2 ? The output of the following code amazes me. #include #include class withAttribute { uint16_t a; uint32_t b; }__attribute__ ((__packed__)); #define HANDLE_SYSV_PRAGMA #pragma packed( 1 ) class withPragma { uint16_t a; uint32_t b; }; #pragma pack() int main() { cout << "sizeof(withAttribute): " << sizeof(withAttribute) << ", sizeof(withPragma): " << sizeof(withPragma) << endl; return 0; } I get: "sizeof(withAttribute): 6, sizeof(withPragma): 8" Why is the structure padded even with pragma packed(1) ? This annoys me a lot because there is no other way I can think of to ensure portability in the alignment of a structure. Thanks for helping S ébastien E. Wailliez