Re: [AD] namespace collision

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Mon, Aug 06, 2001 at 04:10:53AM -0700, Michael Bukin wrote:
> Laurence Withers <lwithers@xxxxxxxxxx> writes:
> 
> > In reply to Bob <ohannessian@xxxxxxxxxx>:
> > >Perhaps this could be done for the whole API. There would be a a #define 
> > >(#define ALLEGRO_API ?) that would prefix all the Allegro functions and
> > >variables with allegro_.
> > >A note could then be placed in the FAQ about what to do in case there is a
> > >namespace collision.
> > 
> > We could also provide an "allegro4.h" header file, which would simply
> > be:
> > 
> > #define ALLEGRO_NAMESPACE
> > #include "allegro.h"
> 
> Maybe it would be better to convert all Allegro-defined symbols to
> prefixed ones and include compatibility header which can be used with
> old projects.  Also it is possible to provide script to convert
> symbols in a file to the new style.  Or maybe keep both styles for
> some time and later move compatibility defines to another header
> file or remove them altogether.

I agree -- simply doing:

    #define allegro_create_bitmap create_bitmap

is pointless because the namespace pollution comes from the
library (i.e. the user still can't use create_bitmap as their
own routine).  The library itself has to use the prefixes, and
the defines would be there just for convenience and
compatibility.

The problem with defines is that they can have nasty
consequences because the preprocessor hasn't a clue what it's
doing.  e.g. for RSXNTDJ we used to define all API variables to be
pointers, e.g.

    #define key (*key)

but this broke things like the DIALOG struct which also have a
`key' member, and function prototypes with `key' parameters.

Aside from this concern, I'd be in favour of the change but it's
a big one.  There are also some inconsistencies -- allegro_init
should not be prefixed, for instance. :)  I also think that the
examples and documentation should only use the current
unprefixed names.  Prefixing is an advanced feature which can be
hidden from novice users.

The prefixes could be turned on by the user defining something
like ALLEGRO_PREFIX_API.

George



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/