INF: SORTDEMO.C - Bind Use and Misuse

ID Number: Q29196

5.10 6.00 6.00a 6.00ax | 5.10 6.00 6.00a 7.00

MS-DOS | OS/2

Summary:

The following article discusses a Microsoft C Compiler version 5.1

program called SORTDEMO.C, which is similar to the program that comes

with QuickBasic version 4.0. The information in this article can be

extended to C versions 6.0, 6.0a, and 6.0ax.

SORTDEMO.C for C version 5.1 is for Microsoft Operating System/2. It

has OS/2 VIO, KBD, and MS-DOS calls. If it has been bound, it can run

with MS-DOS and with real mode Microsoft OS/2, as well as with

protected mode Microsoft OS/2.

More Information:

The following information details the correct way to run SORTDEMO.C

(for a system targeting MS-DOS):

cl /Lp /Zp sortdemo.c

bind sortdemo.exe c:\c\lib\doscalls.lib c:\c\lib\api.lib apilmr.obj

The following is a list of several incorrect ways to run SORTDEMO.C,

the results, and problems (for a system targeting MS-DOS):

1. Command: cl /Fb /Lp sortdemo.c (/Fb means to bind the application)

Result: It links and appears to bind, but it hangs the computer

when it is run with MS-DOS.

Problem: APILMR.OBJ also must be bound. It must perform a separate bind.

2. Command: cl /Fb /Lp sortdemo.c apilmr.obj

Result: It links and appears to bind, but it hangs the computer

when it is run with MS-DOS.

Problem: APILMR.OBJ must be bound with the application because

the application makes VIO calls and it accesses the near heap.

Perform a separate bind (there is no way to bind in APILMR.OBJ

from the cl compile line).

3. Command: cl /Lp sortdemo.c /link doscalls.lib api.lib

Result: The linker gives the error: __acrtused multiply defined

error.

Problem: You should link only DOSCALLS.LIB. Bind it if it will be

used with MS-DOS.

4. Command: cl sortdemo.c

Result: The linker gives 13 unresolved externals, such as

KBDCHARIN, VIO*, and DOS*.

Problem: SORTDEMO.C is a Microsoft OS/2 application. The program

must be compiled using the /Lp switch and then bound if it will be

used with MS-DOS.

5. Command: cl /Lp sortdemo.c or cl /Lp /Zp sortdemo.c

Result: It works correctly when run with MS OS/2. To run it with

MS-DOS, you must bind it using the following:

bind sortdemo.exe c:\c\lib\doscalls.lib c:\c\lib\api.lib apilmr.obj

Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00