[Python-Dev] GC head alignment issue

Neil Schemenauer nas@python.ca
Fri, 12 Oct 2001 07:08:07 -0700


Paul Svensson wrote:
> On Thu, 11 Oct 2001, Tim Peters wrote:
> >[Paul Svensson]
> >> #define gc_next	gc_internals.internal_gc_next
> >Yuck.
> Why do you consider this abuse ?  This pattern is used all over the place,
> you can study it for example in the system headers for linux of glibc.
> It's perfectly legitimate to not want to spread knowledge of the innards
> of a struct (it should be wrapped another layer, yes) all over the place.

Huh?  Say I include a header that abomination in it.  Now consider the
following line of code:

    PyGC_Head *gc_next;

Oops.  The only reasonable alternative to Tim's approach that I can
think of would be:

  #define GC_NEXT(op) ((AS_GC(op))->gc.gc_next)
  #define GC_PREV(op) ((AS_GC(op))->gc.gc_prev)
  #define GC_REFS(op) ((AS_GC(op))->gc.gc_refs)

I don't think that's any better.

  Neil