delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/14/14:00:41

Date: Mon, 13 Oct 1997 22:31:29 +0000 ( )
From: "Gurunandan R. Bhat" <grbhat AT unigoa DOT ernet DOT in>
To: hg211 AT hszk DOT bme DOT hu
Cc: djgpp AT delorie DOT com
Subject: Re: GNU C++ Error or a feature or what?
Message-Id: <Pine.LNX.3.91.971013223035.120A-100000@aditya.unigoa.ernet.in>
Mime-Version: 1.0

On Tue, 14 Oct 1997, Herman Geza wrote:

> 	Hi there!
> 
> 	I have a little problem with GNU C++. When I make a struct type,
> 	and I add __attribute__((packed)), it doesn't work. The compiler
> 	behaves as if the __attribute__((packed)) wasn't there...
> 	If I compile my program with simple C, it works. 

I suspect the reason for this may be the one given in Sec 22.9 of the
DJGPP FAQ. In the absence of a code snippet, I can only guess and I hope I
am right! One possible reason is that the syntax for declaring
__attribute__ ((packed)) differs slightly between C and C++. In C++, you
need to declare the attribute after *every* member of the struct. For
example: 

struct tag{
	type1 member1 __attribute__ ((packed));
	type2 member2 __attribute__ ((packed));
	...
	typen membern __attribute__ ((packed));
} instance;

In C this may be written only once at the end.

I hope this helps! 


- Raw text -


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