From: "Agust Karlsson" <Gusti@pallas.dk>
To: "Alexandre Courbot" <Alexandre.Courbot@lifl.fr>,
"Cédric Lucantis" <cedric.lucantis@caramail.com>,
gcc-help@gcc.gnu.org
Subject: RE: struct and members addresses
Date: Thu, 24 Apr 2003 11:18:00 -0000 [thread overview]
Message-ID: <E8B61FD29D18EE4F849311F6423A9AF41DDC01@intermail.pallas.dk> (raw)
Or to be sure you could use
__attribute__ ((packed))
I.e.
struct foo
{
any_type first_member;
} __attribute__ ((packed)) ;
Gústi
--
Agust Karlsson mailto:gusti@pallas.dk
Pallas Informatik A/S http://www.pallas.dk
Allerød Stationsvej 2D Tel.: +45 48 10 24 10
DK-3450 Allerød Fax.: +45 48 10 24 01
> -----Original Message-----
> From: Alexandre Courbot [SMTP:Alexandre.Courbot@lifl.fr]
> Sent: Thursday, April 24, 2003 1:16 PM
> To: Cédric Lucantis; gcc-help@gcc.gnu.org
> Subject: Re: struct and members addresses
>
>
> > struct foo
> > {
> > any_type first_member;
> > };
> >
> > struct foo my_struct;
> >
> > void * addr1 = &my_struct;
> > void * addr2 = &my_struct.first_member;
> >
> > /* ----------------------------------*/
> >
> > can I be sure that `addr1' will be equal to `addr2' ?
>
> In C, I think you can safely. In C++, if your struct has virtual methods, the
> adress won't be the same since I think GCC puts the vtable at the beginning
> of the struct. But as long as you don't use virtuals, it should be ok AFAIK.
>
> Alex.
>
next reply other threads:[~2003-04-24 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-24 11:18 Agust Karlsson [this message]
[not found] <616BE6A276E3714788D2AC35C40CD18DC3E972@whale.softwire.co.uk>
2003-04-24 13:25 ` Rupert Wood
-- strict thread matches above, loose matches on Subject: below --
2003-04-24 12:58 Martin York
2003-04-24 11:01 Cédric Lucantis
2003-04-24 11:15 ` Alexandre Courbot
2003-04-24 11:29 ` Andrea 'fwyzard' Bocci
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=E8B61FD29D18EE4F849311F6423A9AF41DDC01@intermail.pallas.dk \
--to=gusti@pallas.dk \
--cc=Alexandre.Courbot@lifl.fr \
--cc=cedric.lucantis@caramail.com \
--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).