www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/18/08:53:14

Sender: tim AT picard DOT skynet DOT be
Message-ID: <3B2DF9C2.75AF6AA6@falconsoft.be>
Date: Mon, 18 Jun 2001 14:53:22 +0200
From: Tim Van Holder <tim DOT vanholder AT falconsoft DOT be>
Organization: Anubex N.V.
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.4-win4lin i686)
X-Accept-Language: en, nl-BE, nl
MIME-Version: 1.0
To: djgpp AT delorie DOT com
CC: lunarorb AT hn DOT vnn DOT vn
Subject: Re: BIG problem with structure alignment!
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010618101450 DOT 22931Q-100000 AT is> <000e01c0f7eb$4e4fc600$910fa2cb AT lunar>
Reply-To: djgpp AT delorie DOT com

Lunar wrote:
> 
> I've read the FAQ. It says if I add an "-fpack-struct" command line option,
> GCC will not align the struct. But in fact, when I try that, sizeof() still
> report 4 bytes as it did before.
> Can you help, please?

With some versions of gcc (including recent DJGPP packages), you can use
a
MSVC-like pragma:

#pragma pack(push, 1)

struct mystruct {
  char mychar;
  short myshort;
} mystructvar;

#pragma pack(pop)

This is a bit cleaner than having to append an __attribute__ tag to
each field.

-- 
Tim Van Holder - Anubex N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019