[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] fra Sun til Linux



On Sat, 26 Jun 1999, Egill Rostrup wrote:

> Findes der et compiler-direktiv, eller anden besværgelse, der sørger
> for den rigtige alignment af elementerne i en data-struktur?

Du kan kontrollere det med: __attribute__((packed))

fx:

struct foobar {
	char c;
	int b;
} __attribute__((packed)) ;

Det fjerner *helt* padding.

Du kan ogsaa sige at en bestemt ting skal have en bestemt alignment:

struct foobar {
	char c;
	int b __attribute__((aligned(8)));
}

Saa vil "b" vaere alignet paa en 8-bytes boundary i stedet for 4 som
normalt.


Og endelig du naevnte enums: Det er muligt du skal bruge -fshort-enums.
Det vil "pakke" alle enums: De vil kun vaere saa lange som noedvendigt,
altsaa en enum der gaar op til 42 vil kun fylde een byte i stedet for 4.

For mere information: LAES info gcc. Der staar det hele. Brug evt. 's' for
at searche hen til fx. "aligned("

-- 
==============================================================================
Erwin Andreasen   Herlev, Denmark <sslug@sslug>          UNIX System Programmer
<URL:http://www.andreasen.org>              <*>         (not speaking for) DDE
==============================================================================




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *