Re: [AD] Proposal for new magic main |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> I thought the main thing was ANSI C ??
It is indeed, and it works under Windows for a console app but nor for a GUI
app (in this latter case, Allegro itself provides the argc/argv stuff to the
user program).
> Besides, I don't think Windows looks for a WinMain symbol at load
> time, that would be even more ridiculous, so there's chance it's
> only the linker that defaults to a WinMain called entry point.
Yes, that's a linking-time problem. More precisely, you tell the linker
(Mingw32, MSVC or Borland C++) whether you want to build a console app (main
entry point), a GUI app (WinMain entry point) or a DLL (DLL init function).
With the Borland C++ linker, you even have to link the right crt0 startup
object code (c0x32.obj, c0w32.obj or c0s32.obj respectively) to your
executable.
> Hmm, this leaves the fact that the wrong arguments will be passed
> to the entry point.
Obviously.
> This could be addressed by a macro to generate argc/argv, which
> would just use argc/argv except on Win32, where it would slice up
> the command line (I see one Win32 program here, taking a LPSTR
> (a disguised char*, I think) to a command line, as third parameter
> which could be strtok'd). Yes, this would have to use cpp and not
> be very pretty, but at least it wouldn't be at the external symbol level.
And you were talking about "dirty macro work" ? ;-)
Take a look at src/win/wsystem.c:_WinMain(): generating the executable name
and the argc/argv stuff is a non-trivial thing.
> This would require a change in the link command though, to include
> this /ENTRY:main option. Is there such a thing as allegro-config
> on Win32, or is this a Unix only thing ?
No allegro-config under Windows, the compilers are pre-configured (i.e there
are standard directories for the header files and the libs).
--
Eric Botcazou
ebotcazou@xxxxxxxxxx