🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42098

Re: DWord alignment of structs

#42098
From: Tein H. Yuan(�K���A)
Date: Tue, 23 Jan 1996 00:00
34 lines
1419 bytes
Jan Eric Hoffmann (am6a002@GEOMAT.math.uni-hamburg.de) wrote:
: I created a struct like this:
: struct {
:   short int a;
:   long int b;
:  } XX;
: Using the sizeof operator tells me that that the size of this struct
: is 8 bytes. I'm parsing a binary file, I need a 6byte struct!
: Is there a command line switch to turn of Dword alignment?

Try to use

	struct XX {
		short int a;
		long  int b;
	} __attribute__ ((packed));

in gcc.

If you cannot make it, you can try
	struct XX {
		short int a __attribute__ ((packed));
		long  int b __attribute__ ((packed));
	};

-- Tein
===========================================================
Tein Horng Yuan (�K���A)
(voice): 886-2-789-9247		(fax): 886-2-783-6444
Email: tyuan@beta.wsl.sinica.edu.tw
URL:   http://phi.sinica.edu.tw/~tyuan/
===========================================================
	�z	��	��	��	�w
===========================================================
Technical Details
Message-ID: <4e1biu$3gm@gate.sinica.edu.tw>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4dg5l7$55s@rzsun02.rrz.uni-hamburg.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 11318c,8d820a5a7679bef4
X-Google-Attributes: gid11318c,public
From: tyuan@beta.wsl.sinica.edu.tw (Tein H. Yuan(�K���A))
Subject: Re: DWord alignment of structs
Date: 1996/01/23
Message-ID: <4e1biu$3gm@gate.sinica.edu.tw>
X-Deja-AN: 136070043
references: <4dg5l7$55s@rzsun02.rrz.uni-hamburg.de>
organization: Computing Center, Academia Sinica
newsgroups: gnu.gcc.help