delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/27/11:15:15

From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to align members/data under gcc/DJGPP?
Date: 27 Jun 2002 14:44:15 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 45
Message-ID: <aff8bv$fo0$1@antares.lu.erisoft.se>
References: <96eb2770 DOT 0206270530 DOT 3d2253dc AT posting DOT google DOT com>
NNTP-Posting-Host: lws256.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Alex Yeryomin (AYeryomin AT excelsior-usa DOT com) wrote:
: Hello,

: I can't find in FAQ (sorry, maybe I missed it), how to align struct
: members under gcc/DJGPP? What is pragma/option doing this? Is there
: some way to specify the alignment only for some piece of code like
: this:

: <- set alignment by 1 byte here to pack all members altogether. how?
: struct zzz
: {
: ...
: };
: <- reset alignment to default. how?

If C, make that:
struct zzz
{
...
} __attribute__((packed));

or something very similar.

It's been reported that that doesn't work properly in C++ and for that
you should use:
struct zzz
{
... __attribute__((packed));
... __attribute__((packed));
};

: Is it possible to align also data object (variables) into the memory?
: F.e., all variables should be alignment by the paragraph 16 bytes.
: How?

Not sure, but perhaps:
int my_int __attribute__((align(16)));

or something like that does the trick. But remember that the section
must be aligned to this as well (a link issue).


Right,

						MartinS

- Raw text -


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