Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!att!cbnewsc!tjr From: tjr@cbnewsc.att.com (thomas.j.roberts) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Using Turbo C with libraries compiled with Microsoft C Message-ID: <1990Jun4.205834.13661@cbnewsc.att.com> Date: 4 Jun 90 20:58:34 GMT References: <10760@medusa.cs.purdue.edu> Organization: AT&T Bell Laboratories Lines: 43 There are several (many ?) differences between Turbo C and Microsoft C. Some of them are harmless, some will kill your program; some will kill MS-DOS, some might even trash your disk(s). THIS IS PROBABLY NOT A COMPLETE LIST! 1) TC returns 4-byte results in AX/DX; MC uses AX/BX (float/double are returned in 8087 Top-Of-Stack register). This will make any large-pointer function misbehave dangerously, and will give erroneous results from any long function. 2) TC and MC use different names for the various segments. This will probably prevent it from linking properly (except for huge model programs), and will cause subtle errors in a huge-model program. 3) TC and MC package library routines differently, so you cannot use both the MC and the TC run-time libraries. If the third-party library depends upon the MC run-time library, this may cause link and/or run-time problems. 4) TC and MC have different requirements for subroutines to preserve register contents. This will cause a serious disaster during execution (write-protect those disks before executing!). 5) The TC run-time library screws around with the console hardware (even if you don't call any of its TEXT or GRAPHICS routines); this can often be minimized by setting directvideo=0. In most cases, even if you manage to get the linker to link the program and libraries without error, it will still die a horrible death when executed (usually taking MS-DOS down, too). In short, I strongly advise against trying to mix compilers in the same program. If you simply cannot afford to buy the other compiler, then you probably can make it work with the following kludges: 1) use TC huge model, and MC large model. 2) wrap every MC library routine with a special assembly routine to satisfy BOTH TC and MC register conventions (MC routine calling MC routine is probably OK as is). This special routine will need to manage DS. Good luck [you will really need it!]. Tom Roberts att!ihlpl!tjrob