mtp@mold.zso.dec.com (Mike Peterson) (05/29/91)
While I'm using Turbo C V2.0, I suspect that this question is applicable to users of MSC as well. So, here goes. I want to build a large memory model library against which small model applications may link. My question is around the multiple modules that comprise the library. For example, the library FOO.LIB is built from the following source modules: foo.c Contains the public API routines, the prototypes for which are in foo.h and are included by the user's application. Compiled with the -ml switch. bar.c Private to the LIB. Routines in foo.c call routines in utils.c misc.c Private to the LIB. Routines in foo.c and bar.c call routines in misc.c. Both bar.c and misc.c have services which call one or more of the public functions in foo.c I want the routines in bar.c and misc.c to be NEAR with respect to foo.c and each other (Apart from those internal routines that call public services). Here's what I think I should do. I'm hoping someone will tell me if I'm wrong or if there are gotchas that I've not taken into consideration: 1) Prototype all of the public library services with the FAR keyword in, say public.h. Public.h, may then be included in the user's application. Now, all calls to the FOO.LIB routines become FAR calls. 2) Compile foo.c with the -ml switch and the other modules with the default (-ms) switch. The compiler will make all calls to bar.c routines and misc.c routines NEAR calls. All calls from routines in bar.c or misc.c to routines in foo.c will be FAR calls. Regards, /mtp -- # # +--------------------------------------------------------------+ # | Michael T. Peterson | mtp@mold.enet.dec.com | # | Digital Equipment Corp. | ...!decwrl!mold.enet!mtp |
Mike.Peterson@sunbrk.FidoNet.Org (Mike Peterson) (05/29/91)
While I'm using Turbo C V2.0, I suspect that this question is applicable to users of MSC as well. So, here goes. I want to build a large memory model library against which small model applications may link. My question is around the multiple modules that comprise the library. For example, the library FOO.LIB is built from the following source modules: foo.c Contains the public API routines, the prototypes for which are in foo.h and are included by the user's application. Compiled with the -ml switch. bar.c Private to the LIB. Routines in foo.c call routines in utils.c misc.c Private to the LIB. Routines in foo.c and bar.c call routines in misc.c. Both bar.c and misc.c have services which call one or more of the public functions in foo.c I want the routines in bar.c and misc.c to be NEAR with respect to foo.c and each other (Apart from those internal routines that call public services). Here's what I think I should do. I'm hoping someone will tell me if I'm wrong or if there are gotchas that I've not taken into consideration: 1) Prototype all of the public library services with the FAR keyword in, say public.h. Public.h, may then be included in the user's application. Now, all calls to the FOO.LIB routines become FAR calls. 2) Compile foo.c with the -ml switch and the other modules with the default (-ms) switch. The compiler will make all calls to bar.c routines and misc.c routines NEAR calls. All calls from routines in bar.c or misc.c to routines in foo.c will be FAR calls. Regards, /mtp -- # # +--------------------------------------------------------------+ # | Michael T. Peterson | mtp@mold.enet.dec.com | # | Digital Equipment Corp. | ...!decwrl!mold.enet!mtp | * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)
frank@cavebbs.gen.nz (Frank van der Hulst) (05/29/91)
In article <1521@rust.zso.dec.com> mtp@mold.zso.dec.com (Mike Peterson) writes: > > I want to build a large memory model library against which small model > applications may link. My question is around the multiple modules that > comprise the library. For example, the library FOO.LIB is built from the ne problem I've come across in attempting to do this is that your routines must not call any of C's library routines... otherwise all the addresses (generated by the call as 32 bits, but expected by the small library routines to be 16 bits) will be screwed up. > > I want the routines in bar.c and misc.c to be NEAR with respect to > foo.c and each other (Apart from those internal routines that call > public services). C You must use the keyword 'near' or 'far' for all addresses, and also you must use prototypes which include 'near' or 'far'. > -- Take a walk on the wild side, and I don't mean the Milford Track. Kayaking: The art of appearing to want to go where your boat is taking you.