Compiler issue...

Archie Cobbs archie at whistle.com
Wed Jan 27 11:08:53 PST 1999


Maxim Kizub writes:
> But this _does_ allocates 'data', which is at least double :-(
> Isn't it better to have some kind of system-specific
> macros that ensures correct align and goes to config.h,
> for example
> 
> // for gcc
> #define DOUBLE_ALIGN double align[0];
> // for another one
> #define DOUBLE_ALIGN \
>  union { \
>          double x; \
>          whatever type y; \
>  } align;

I'm confused.. I thought the purpose of declaring

   int foo[0];

was so that you could put this at the end of a structure
which was intended to have an arbitrarily long array at the
end of it.. eg:

  struct foo {
    char     *name;
    int      length;
    int      values[0];
  } *fp;
  fp = (struct foo *) malloc (sizeof(struct foo) + (len * sizeof(int)));
  fp->length = len;
  memset(fp->values, 0, len * sizeof(*fp->values));

If all you want is *alignment* in a structure, then this would
be the more appropriate thing to do:

  #ifdef __GNUC__
  #define ALIGN(n)   __attribute__ ((aligned (n)))
  #else
  #define ALIGN(n)  ... whatever ..
  #endif

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com


More information about the kaffe mailing list