Lots of #defines OK?

Patrik Stridvall ps at leissner.se
Thu Jul 19 11:10:36 CDT 2001


> I would like to get rid of the "hardcoded" offset into the glyph name
> array and replace it with a macro ('GN_exclam', for example). 
>  Each font
> data file could then simply include a header that gets 
> regenerated when-
> ever the glyphlist is changed -- eliminating the current 
> requirement to
> regenerate all the font data.
> 
> Anyone see any problems with this?  (There are currently 1258 built-in
> glyph names.)

Not really, but as an alternative solution you could has a structure
instead of an array like:

typedef struct {
  GLYPHNAME A;
  GLYPHNAME AE;
  GLYPHNAME AEacute;
  GLYPHNAME AEsmall;
  /* ... */
} GLYPHNAMES;

Perhaps this is better since it doesn't use the preprocessor.

However I'm not sure if all C compilers supports 1258 structure members.
Another possible problem is alignment on some platforms if you must
be able for iterate over it and use it as and array. Of course 
you can simply have a seperate array of pointers like:

GLYPHNAMES glyphnames = {
  /* ... */
};

GLYPHNAME *pGlyphnames[] = {
  &glyphnames.A;
  &glyphnames.AE;
  &glyphnames.AEacute;
  &glyphnames.AEsmall;
  /* ... */
};




More information about the wine-devel mailing list