From: Sebastien.Wailliez@alcatel.be
To: gcc-help@gcc.gnu.org
Subject: Pragma question
Date: Tue, 20 Feb 2001 07:57:00 -0000 [thread overview]
Message-ID: <C12569F9.00578DF9.00@bemail05.net.alcatel.be> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
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 <stdint.h>
#include <iostream>
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
next reply other threads:[~2001-02-20 7:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-20 7:57 Sebastien.Wailliez [this message]
2001-02-20 9:15 ` Lewin A.R.W. Edwards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C12569F9.00578DF9.00@bemail05.net.alcatel.be \
--to=sebastien.wailliez@alcatel.be \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).