Re: [AD] alternate entry point for allegro programs

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


On August 1, 2004 12:46 am, Michael Benfield wrote:
> I love Allegro but I have a request for a possible change to Allegro's
> internal workings.
>
> Is the END_OF_MAIN stuff and changing the user's main() function to
> _mangled_main() really necessary? Couldn't all the stuff that Allegro's
> main or _WinMain does just be taken care of by a function that is
> called by the user, rather than by a function that hijacks the
> program's entry point? As far as I can tell the only thing that the
> END_OF_MAIN stuff does that couldn't be done by a normal function is
> allowing the user to use main() rather than WinMain() on Windows... and
> while that's nice, I'm not sure it's something a game library should
> bother with, and even if Allegro must do that, it seems like that
> functionality could be separated from all the code that happens in
> _WinMain or main.
>
> My problem is this: I am trying to create an OCaml wrapper for Allegro.
> If I compile a native code binary linked to Allegro, the entry point of
> the program is going to be with my OCaml code, not with Allegro. So
> there's no way to get to Allegro's main() function.
>
> On the other hand, if anyone knows a way I CAN get to Allegro's main()
> function without the program starting there, I'd love to hear it.

Currenty there is no way to change the point that allegro assumes is the 
entry. But I've tied allegro into a dll and executed library functions from 
it directly.

Either use the ALLEGRO_NO_MAGIC_MAIN define or, if you can, ignore it all, 
have a dummy "main() {} END_OF_MAIN()".

The ALLEGRO_NO_MAGIC_MAIN define tells the allegro headers to not do any of 
the magic regarding main.

The reason for the magic main stuff is to act as much like the old DOS allegro 
as possible, and be as portable to other platforms at the same time. In unix, 
and windows, special things are required, that alot of coders really should 
not need to worry about, like WinMain in windows and allegro needing some 
info from argv in unix (and I think theres some other stuff that it does in 
unix, but I don't know for certian)

> Thanks.
>
> Mike Benfield
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by OSTG. Have you noticed the changes on
> Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
> one more big change to announce. We are now OSTG- Open Source Technology
> Group. Come see the changes on the new OSTG site. www.ostg.com

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx
http://strangesoft.net




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