Date: Thu, 22 Sep 1994 10:19:33 -0400 (EDT) From: Chris Tate To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Using GCC for Windows apps/DLL's Someone just posted another question about the possibility of using GCC to create Windows DLL's, so I thought I'd dig up this post I'd written a while ago, but didn't successfully mail to the list last time. I'd be interested to hear anything that other can contribute to this. Tom Roden (tom AT batc DOT allied DOT com) writes: > > I was wondering if anyone has heard if GCC has been or is being modified to > produce Windows NT 32 bit (ie. PE format) executables. It seems that this > would be a likely and popular target (Windows NT that is). > > Also, if this isn't already being done, where would one start such a task? > > 1) The NT API has certain calling conventions which would have to be > supported by the compiler. Stan Shebs, once of Apple and now with Cygnus (a private company that does GNU-based development on a contract basis?), worked for quite some time on porting gcc/g++ 2.x to the Macintosh, which shares with NT the fact that its toolbox uses Pascal calling conventions. It turns out that making gcc understand Pascal calling conventions is *very* hard. Here are the basic differences: 1. In C, the arguments are pushed right-to-left. In Pascal, they're pushed left-to-right. 2. In C, it's the caller's responsibility to clean up the arguments from the stack. In Pascal, it's the called function's responsibility. 3. In C, return values can be passed in registers (as I *believe* is usually done). Pascal functions return values on the stack. Stan was actually rewriting the basic *type* mechanism to get clean support for pascal functions; that's how pervasive the differences are. There are a couple of ports of gcc 1.x to the Mac, which shows that it's not an insurmountable obstacle, but I wouldn't attempt it unless you were quite familiar with compiler design in general, and gcc in particular. -------------------------------------------------------------------- Christopher Tate | "Apple Guide makes Windows' help engine MSD, Inc. | look like a quadruple amputee." fixer AT faxcsl DOT dcrt DOT nih DOT gov | -- Pete Gontier (gurgle AT dnai DOT com)