Re: [AD] Proposal for new magic main

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


On Fri, Feb 22, 2002 at 10:38:39AM +0100, Eric Botcazou wrote:
> > IMHO, the executable name is pretty irrelevant, but that's a
> > side issue.
> 
> Not that much of a side issue, as we have in the API:
> 
> void get_executable_name(char *buf, int size);
> Fills buf with the full path to the current executable, writing at most size
> bytes. This generally comes from argv[0], but on Unix systems if argv[0]
> does not specify the path, we search for our file in $PATH.
> 
> Is there any mean to retrieve the argv[0] parameter under Unix, apart from
> the main() entry point ? If so, we could get rid of the magic main under
> Unix.

Not in general -- asking about any Unix is a bit like asking
about any compiler under the sun. :)  Linux has some ways (I
think Allegro uses them) but it's not reliable.

Getting the executable's directory is a weird concept though; in
Unix you may very well not have write access there, and it's
abnormal for programs to store data files in the same directory
as their executable.  I wondered before the 3.9 WIPs whether it
would just be better to return /usr/local/share/$progname, or
something like that.  But personally I think using the current
directory is the best way to let a program find its files. :)
Of course it's too late for 4.*, and maybe for 5.* too, I
haven't been paying attention.

> I agree that we could get rid of the __crt0_* stuff. But we are stuck with
> the executable name for 4.1.x because of the API function.

Hmm.  If only it was: get_executable_name (argv[0], buf, size).
:)  In the end, on generic Unix at least, it ends up having to
search the $PATH for the binary, and might not even find it.

> > And if only one platform needs END_OF_MAIN, nobody will bother
> > with it on other platforms. :(
> 
> It's not really our problem, I think, that users don't follow the rules.

No, it's not.  Sometimes it helps to force them though, for
their own sake. :)  It's a bit like the keyboard and mouse
polling routines -- nobody has really ever called them, so
they're essentially useless; Allegro can't be ported to a system
that needs polling after all, because 99% of games just wouldn't
run.  END_OF_MAIN is a much simpler issue though, it's true. :)

George



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