[ale] Ms -> Linux porting pointer sought

Joseph Knapka jknapka at earthlink.net
Thu May 15 08:03:13 EDT 2003


John Mills <johnmills at speakeasy.net> writes:

> Bob -
> 
> Thanks for the note.
> 
> On Wed, 14 May 2003, Transam wrote:
> 
> > On Wed, May 14, 2003 at 07:13:50PM -0400, John Mills wrote:
> 
> > > Anyone know of a FAQ or crypto-FAQ on this, covering things like 
> > > equivalent types, etc? I'm making up an environment-sensing include file 
> > > to define handy symbols having different but equivalent meaning in the 
> > > worlds of MsVS/VC++ and GNU/Linux.
>  
> > Try the books:
> > 
> >      Integrating Linux and Windows
> >      Linux for Windows Administrators
> 
> Thanks - those look promising (particularly the first one, for what I'm
> doing).
> 
> > If you want to specifically #ifdef code in an include file, have a look
> > at some of the defined symbols in each environment and use one.
> 
> That's what I'm doing. Numeric types have not been a problem to define,
> but I'm looking for *nix synonyms for generic 'HANDLE' (U16, I guess?)  
> and 'SOCKET'. I don't have much in the way of MsWin examples to look at, 
> compared to all the *nix sources. I admit to being 'Windows challenged'.

IIRC a HANDLE is essentially a void*. But HANDLEs are used for
resource acquisition all over the place in Windows: you have HANDLEs
to files, windows, paintbrushes, shared memory areas, etc etc etc etc
etc... In all those different cases, the data structure pointed to by
the HANDLE is different, and only the Win32 implementation knows what
to do with them (this is fine API design, BTW; Microsoft does actually
do some things right. Well, one thing, anyway). Anything that uses a
Windows HANDLE is generally going to require rewriting for Linux.

In Linux a socket is represented by an int. In Windows, it's another
kind of HANDLE, I think, but code that uses sockets on either OS
shouldn't care about the representation of sockets. Therefore, if you
use a "typedef int SOCKET" on the Linux side, most Winsock code should
compile verbatim, except the bits that initialize the Winsock library
(which is redundant on Linux anyway).

Cheers,

-- Joe
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list