www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/03/13:43:39

From: av568 AT rgfn DOT epcc DOT edu (Beautiful Savior Lutheran Church)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C++ packed structs..
Date: 28 Feb 1997 20:41:55 GMT
Organization: The Rio Grande Free-Net, El Paso Community College, El Paso, TX
Lines: 37
Message-ID: <5f7fuj$c4i@news.epcc.edu>
References: <33142636 DOT C9D AT cmr DOT no>
NNTP-Posting-Host: rgfn.epcc.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Olav Kindt (kindt AT cmr DOT no) wrote:
> Hi all,  

> I just read from the faq 22.9 about packing struct.

> I have a clarification question regarding that:

> The faq says that a struct like

> 	struct {
> 		char name[7];
> 		unsigned long offset;
> 		double quality;
> 	} __attribute__ ((packed));

> will be packed correctly when compiled as C-source. Then it says that
> C++ doesn't allow this, and you must declare each struct field with the
> packed attribute.

> Does this in effect mean this :

> 	struct {
> 		char name[7] __attribute__ ((packed));
> 		unsigned long offset __attribute__ ((packed));
> 		double quality __attribute__ ((packed));
> 	};


> I've had some weird problems lately with my program, so
> I'll really appreciate an answer to this. Thanks in advance.

This is correct. AFAIK, __attribute__((packed)) not working in C++ mode 
is a problem with g++, not with C++ itself.

--
Beautiful Savior Evangelical Lutheran Church - av568 AT rgfn DOT epcc DOT edu
We have what you need-- A Savior!

- Raw text -


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