Re: [AD] dmc build questions

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


On 2007-06-10, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> I created a makefile and platform file for the DMC compiler based on 4.2 SVN.
> 
> Questions:
> 
> 1) What is #define ALLEGRO_USE_CONSTRUCTOR for? I have it undefined
> currently. (I had to undefine it to get MinGW to work as well.)

If defined, we use the gcc constructor function attribute.  If an object
file is linked into a program, then any constructor functions in that
object file will be executed before main().  We use this feature to
avoid pulling in Allegro object files unnecessarily when static linking.

e.g. install_sound() potentially initialises the MIDI subsystem so, if
coded directly, calling install_sound() would pull in midi.o whether the
user program actually uses any MIDI functions or not.  If the user calls
a MIDI-related function (linking in midi.o) we make the constructor in
midi.o set up a pointer _al_linker_midi, which is otherwise NULL.  Now,
install_sound() only calls MIDI functions through _al_linker_midi,
severing the direct link to midi.o.

Without ALLEGRO_USE_CONSTRUCTOR we call all the constructor functions
when Allegro is initialised, which just means everything is always
pulled in.

Anyway, this was when Allegro could be considered "big" and people still
cared about this sort of thing.

Peter





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