Groups | Search | Server Info | Login | Register


Groups > comp.lang.c.moderated > #411

Re: distributing data across a structure (new to c please help)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!feed.news.qwest.net!mpls-nntp-02.inet.qwest.net!news-out.octanews.net!mauve.octanews.net!newspump.sol.net!posts.news.megabitz.net!nnrp2-asbnva.megabitz.net!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c.moderated
Subject Re: distributing data across a structure (new to c please help)
Date Mon, 20 Aug 2012 22:10:12 -0500 (CDT)
Organization None to speak of
Sender clcm@herd.plethora.net
Approved clc@plethora.net
Message-ID <clcm-20120820-0002@plethora.net> (permalink)
References <clcm-20120809-0001@plethora.net> <clcm-20120820-0001@plethora.net>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Return-Path <news@eternal-september.org>
X-Original-to clcm@plethora.net
X-Auth-sender U2FsdGVkX189BV0RE+fyj4L7ACkfls/B
Cancel-Lock sha1:UNguqI+mKc2vstA1BBqwnVnss/k= sha1:PjWQYEC5B3AqwRXXSVrKy6Vo/WQ=
Content-Type text/plain; charset=us-ascii
Mime-Version 1.0
Delivered-To clcm@localhost.plethora.net
Lines 28
NNTP-Posting-Date 21 Aug 2012 02:03:29 GMT
NNTP-Posting-Host 7b487145.news.megabitz.net
X-Trace DXC=;Wb8>kXWY8DiXj:d?_<Q]C><6FU_Q:4mB^W\Y;gN2lOM:j84KQkNLAGA6:QDPM9FeM7d@DE\31QYEMoRO]O40E3H`H03LY\jMh@Kn027`?MeV@
X-Complaints-To abuse@megabitz.net
Xref csiph.com comp.lang.c.moderated:411

Show key headers only | View raw


Dennis Yurichev <dennis_mailing_lists@conus.info> writes:
[...]
> Also, do not forget about C compiler may align all struct members by 4
> bytes on x86 and 8 bytes on Win64. 
> Since Windows PE file fields are all differently sized and this is very
> important, please consult "pack" pragma:
> http://msdn.microsoft.com/en-us/library/2e70t5y1(v=vs.80).aspx

A compiler is unlikely to align *all* struct members on 4-byte or 8-byte
boundaries.  For example, given:

    struct foo {
        char x;
        char y;
    };

I'd expect offsetof(struct foo, y) to be 1 and sizeof (struct foo) to be
2 for most compilers.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.

Back to comp.lang.c.moderated | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

distributing data across a structure (new to c please help) nwdpil <mkeput@gmail.com> - 2012-08-09 20:32 -0500
  Re: distributing data across a structure (new to c please help) James Kuyper <jameskuyper@verizon.net> - 2012-08-10 00:43 -0500
  Re: distributing data across a structure (new to c please help) Dennis Yurichev <dennis_mailing_lists@conus.info> - 2012-08-20 14:17 -0500
    Re: distributing data across a structure (new to c please help) Keith Thompson <kst-u@mib.org> - 2012-08-20 22:10 -0500
    Re: distributing data across a structure (new to c please help) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-08-20 22:11 -0500

csiph-web