This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Struct allocation on a 4 byte boundary: Syntax error?


Aiee :)

   Hello!

   I don't know if this is the right mailing list, so I apologize
   if I'm wrong :)

   I'm trying to allocate a struct on a 4 byte boundary but I get
   error while compiling (gcc version 2.7.2.3).

   I also don't know if I'm doing right ;)

   Here attached here's the simple test program.
   Any ideas?

Thx && bye bye

                     -- gg sullivan
   
-- 
Lorenzo Cavallaro	`Gigi Sullivan' <sullivan@sikurezza.org>

LibRNet Project Home Page: http://www.sikurezza.org/sullivan
LibRNet Mailing List: librnet-subscribe@egroups.com

Until I loved, life had no beauty;
I did not know I lived until I had loved. (Theodor Korner)
#include <stdio.h>

struct foo {
   int   a;
   int   b;
   char  c;
};

int
main(void)
{
   struct foo *foobar;

   foobar = (struct foo *) malloc(sizeof(struct foo) + 3);
   foobar = (struct foo *) (((char *) foobar + 3) & ~3);
   exit(0);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]