🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50843

alignment with gcc2.3.3 under linux

#50843
From: Hein Roehrig
Date: Thu, 05 Aug 1993 18:42
51 lines
1643 bytes
/*
Hi gcc experts,

I have a little problem using gcc 2.3.3 under Linux 0.99pl5:
the __attribute__ ((aligned(n))) directive seems to work only if I
request
a larger alignment. Yet I need a struct where a char is immediately
followed 
by a long, i.e. I need byte alignement.
The following does not produce the results I would like to see:
*/


#include <stdio.h>
#include <stdlib.h>


struct a_struct
{
charb;
longl __attribute__ ((aligned(1)));
};


#define PRINT(x) print(#x, x)
void print(char *s, int i)
{
printf("%s = %i\n", s, i);
}


main()
{
struct a_struct a_struct_var;
PRINT(sizeof(long));                  /* Is 4, alright */
PRINT(sizeof(struct a_struct));       /* Should be 1+4=5, but is 8! */
return(EXIT_SUCCESS);
}

/*
I tried many combinations of __attribute__ directives, but none produces
the effect I desired. Is there any other way to achive byte alignment
within a struct or is this just a RTFM of mine?

Thank you very much in advance for any hint,

hein
*/
----
eurom: Free Multiline Unix BBS                    Home of the FSAG
Frankfurt/Main,Germany                       Data: ++49-69-6312934
Technical Details
Message-ID: <CBAuMF.AGM@eurom.fsag.rhein-main.de>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!incom!odb!eurom!hein

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,1f492fbe7fd5dee5,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-08-06 11:39:11 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!incom!odb!eurom!hein
From: hein@eurom.fsag.rhein-main.de (Hein Roehrig)
Subject: alignment with gcc2.3.3 under linux
Message-ID: <CBAuMF.AGM@eurom.fsag.rhein-main.de>
Organization: Godcorp
Date: Thu, 5 Aug 1993 18:42:14 GMT
Lines: 51