Re: [AD] umain in unsharable part

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


On Sun, Mar 11, 2001 at 04:07:32PM +0100, m.versteegh@xxxxxxxxxx wrote:
> Looking in allegro's umain.c shows it's not too hard to add allegro's
> initialisation to your own main either.

IMHO Allegro's initialisation is of dubious usefulness anyway --
the only thing __crt0_* are used for is get_executable_name.
This doesn't have very many uses, and in Linux there's a better
way to find it (cat /proc/(pid)/cmdline).  We discussed this
method some time ago, I don't remember what the results were but
it seems they weren't included in the library.

But even if the END_OF_MAIN trickery doesn't gain anything very
significant on Unix, there's no argument for removing it because
it's essential on Windows.  The only argument for removing it in
Unix is that it gets rid of the annoying renaming of the `main'
function, and so might confuse debuggers a bit less.  So I'm not
really suggesting that, just commenting that it doesn't matter
much if you ignore the problem for your Fortran/Python/whatever
ports -- there's no real need to set argc and argv, they get
reasonable default settings anyway.

I wasn't aware of the problem with overriding functions in
shared libraries.  Actually, it seems to work, apart from the
complaint about `_mangled_main_address' -- if this variable
exists (a void *, but that doesn't matter much), then there's no
problem linking, and my main function was called in preference
to Allegro's.  I don't know how reliable this is though.

Something else which may be useful is the linker's `wrapper'
feature, allowing you to rename a symbol from one object file
making it appear differently to the others.  You could use this
to rename the Fortran or Python `main' function to something
else (e.g. Allegro's `_mangled_main'), and set up the
_mangled_main_address variable as Allegro expects, pointing at
this function.  That all feels rather hairy, though.

George

-- 
Random project update:
09/05/2000: Libnet 0.10.8 uploaded -- a few bugfixes
        http://www.canvaslink.com/libnet/  (try changes-0.10.8.txt)



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