sizeof a struct

Discussion in 'C Programming' started by Phui Hock, Nov 6, 2003.

  1. Phui Hock

    Phui Hock Guest

    Phui Hock, Nov 6, 2003
    #1
    1. Advertising

  2. Phui Hock

    Richard Bos Guest

    (Phui Hock) wrote:

    > I've found this article "What should sizeof (struct xyzzy) return?" at
    > http://www.delorie.com/djgpp/v2faq/faq22_11.html. Just thought of
    > sharing it with anyone who came across the same problem.


    While the solutions on that page are (for obvious reasons) partly
    system-specific, in particular the attribute-packed one, its explanation
    of the problem is good, IMO.

    Richard
    Richard Bos, Nov 6, 2003
    #2
    1. Advertising

  3. Phui Hock

    Villy Kruse Guest

    On Thu, 06 Nov 2003 11:17:39 GMT,
    Richard Bos <> wrote:


    > (Phui Hock) wrote:
    >
    >> I've found this article "What should sizeof (struct xyzzy) return?" at
    >> http://www.delorie.com/djgpp/v2faq/faq22_11.html. Just thought of
    >> sharing it with anyone who came across the same problem.

    >
    >While the solutions on that page are (for obvious reasons) partly
    >system-specific, in particular the attribute-packed one, its explanation
    >of the problem is good, IMO.
    >


    Just need to note that some processors don't tolerate unaligned access
    at all. You get a program crash rather than some performance penalty.

    Of course, djgpp is limited to Intel x86 only so this doesn't apply.

    Villy
    Villy Kruse, Nov 6, 2003
    #3
  4. Darrell Grainger, Nov 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek
    Replies:
    7
    Views:
    24,303
    Ron Natalie
    Oct 14, 2004
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    613
    CBFalconer
    Apr 10, 2004
  3. Chris Fogelklou
    Replies:
    36
    Views:
    1,346
    Chris Fogelklou
    Apr 20, 2004
  4. Vinu
    Replies:
    13
    Views:
    1,383
    Lawrence Kirby
    May 12, 2005
  5. blufox

    sizeof( int ) != sizeof( void * )

    blufox, May 22, 2006, in forum: C Programming
    Replies:
    2
    Views:
    543
    Joe Smith
    May 22, 2006
Loading...

Share This Page