Re: [AD] A small bugfix in allegro_exit |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> Speaking of which, does anyone know the rationale to use
> constructor routines with GCC ? It means stuff is called before
> allegro_init is called, which is not very friendly.
They make it possible to avoid fake dependencies between modules, for example
the graphics module and the mouse module. Because set_gfx_mode() changes the
mouse range, it used to contain a call to set_mouse_etc(), which causes the
mouse module to be linked to the executable whenever the graphics module is,
even though the mouse module is not used at all.
Laurence implemented a registration scheme that lets each module register its
interface if it is present, so there is now an indirection in set_gfx_mode()
and linking the graphics module doesn't cause the mouse module to be linked
any longer.
But, in order for a module to register itself, its registration routine (for
example _mouse_constructor in mouse.c) must be called from the core library
so normally there is again a linking dependency, this time between the core
library and the mouse module (see the beginning of install_allegro),
_except_ if this registration routine is called through a constructor
because there is no explicit call to constructors in the code.
> Also, it means that the image loader/saver list, for instance,
> is cleaned to the start state (eg, PCX/TGA/BMP/LBM), and not
> entirely.
Could you elaborate a bit?
--
Eric Botcazou