Message-Id: <199809220334.EAA08027@rochefort.ns.easynet.net> Comments: Authenticated sender is From: "George Foot" To: M DOT A DOT Bukin AT inp DOT nsk DOT su Date: Tue, 22 Sep 1998 04:27:08 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: DJGPP and windows? Reply-to: mert0407 AT sable DOT ox DOT ac DOT uk CC: djgpp AT delorie DOT com Precedence: bulk On 22 Sep 98 at 9:08, M DOT A DOT Bukin AT inp DOT nsk DOT su wrote: > "George Foot" writes: > > > Does anyone know where the source code to NTBIND can be found? > > I want to add some switches to it -- at the moment it makes > > console applications if it finds a `main' function, whether or > > not a `WinMain' exists, and I need a switch to tell it exactly > > what type of application to make. This is because WinAllegro > > provides a wrapper WinMain function that calls `main' as if the > > program was a normal console application. I can't use this > > wrapper because as soon as I make `main' NTBIND decides it > > really is a console application. > > You can add the following code to "allegro.h": > > #ifdef __WINDOWS__ /* Not sure about __WINDOWS__ define. */ > int _Wrapper_for_main (); > #define main _Wrapper_for_main > #endif > > And then in WinMain either include "allegro.h" and call `main' or call > `_Wrapper_for_main' directly. This code in the header should be > inside `extern "C" {}' construct and user program must include > "allegro.h" in the module which declares `main', but I think that > including "allegro.h" in every file in project is required, as it may > provide compatibility between different platforms. > > Users might be confused by getting error messages from compiler > that point to `_Wrapper_for_main' which is not in the source file, so > this wrapping can be documented somewhere. Thanks, but I'd thought of that and it's not quite good enough because the `WinMain' function in the WinAllegro DLL tries to call `main'. At the moment I'm providing my own WinMain function which calls the wrapper function, and doing just about exactly what you wrote above to make it transparent to the normal code. Another solution that's sprung to mind is to have three levels -- the `WinMain' function defined in the DLL should call a function called `winallegro_main', which has `main'-like parameters. The DLL should also contain a `winallegro_main' function which calls `main' with the given parameters, and returns its return value. Then the user can define `main' if their compiler supports it without making a console application, or define `winallegro_main' if it's going to barf, or define `WinMain' if they want direct control over the startup process. This all involves changes to the WinAllegro DLL though, which can only be built with MSVC, and the author won't be available until the weekend. It's no big problem, I was just looking for a quicker short-term solution. I've now ported over 30 DJGPP + DosAllegro programs to RSXNTDJ + WinAllegro, and it gets a little tedious! :) -- george DOT foot AT merton DOT oxford DOT ac DOT uk