delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/09/03:16:06

Message-Id: <199605090709.DAA29191@delorie.com>
Date: Thu, 09 May 96 09:58:29 LIT
From: Martynas Kunigelis <martynas DOT kunigelis AT VM DOT KTU DOT LT>
Subject: Re: Structure size
To: Gert-Jan Schoenmakers <tgtcgs AT tc0 DOT chem DOT tue DOT nl>,
DJGPP mailing list <djgpp AT delorie DOT com>
In-Reply-To: Your message of Wed, 08 May 1996 13:45:32 +0200

just put #pragma pack(1) and #pragma pack() around your structure like this:

#pragma pack(1)

struct foo {
  ...
};

#pragma pack()

or use 2 or 3 or whatever as an argument for the 1st pragma if you want 2 or
3 or whatever byte alignment of structure fields.

Martynas

P.S. you could use __attribute__ ((packed)), but it currently doesn't work
     with GNU C++. Allthough GNU guys claim using #pragmas is wrong, #pragma
     pack is quite portable, at least Watcom and Microsoft compilers support
     it AFAIK.

- Raw text -


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