22.02.2014 Views

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>DOS</strong> Programming Guide<br />

2.2 Building and Running the Sample <strong>DOS</strong> Application<br />

To compile and link our example program which is stored in the file HELLO.C, enter the<br />

following command:<br />

C>wcl /l=dos hello.c<br />

The typical messages that appear on the screen are shown in the following illustration.<br />

C>wcl /l=dos hello.c<br />

WATCOM C/C++16 Compile and Link Utility<br />

Copyright by WATCOM International Corp. 1988, 2000. All rights reserved.<br />

WATCOM is a trademark of Sybase, Inc. and its subsidiaries.<br />

wcc hello.c<br />

WATCOM C16 Optimizing Compiler<br />

Copyright by WATCOM International Corp. 1984, 2000. All rights reserved.<br />

WATCOM is a trademark of Sybase, Inc. and its subsidiaries.<br />

hello.c: 6 lines, included 155, 0 warnings, 0 errors<br />

Code size: 17<br />

WATCOM Linker<br />

Copyright by WATCOM International Corp. 1985, 2000. All rights reserved.<br />

WATCOM is a trademark of Sybase, Inc. and its subsidiaries.<br />

loading object files<br />

searching libraries<br />

creating a <strong>DOS</strong> executable<br />

Provided that no errors were encountered during the compile or link phases, the "hello"<br />

program may now be run.<br />

C>hello<br />

Hello world<br />

If you examine the current directory, you will find that two files have been created. These are<br />

HELLO.OBJ (the result of compiling HELLO.C) and HELLO.EXE (the result of linking<br />

HELLO.OBJ <strong>with</strong> the appropriate <strong>Watcom</strong> C/C++ libraries). It is HELLO.EXE that is run by<br />

<strong>DOS</strong> when you enter the "hello" command.<br />

2.3 Debugging the Sample <strong>DOS</strong> Application<br />

Let us assume that you wish to debug your application in order to locate an error in<br />

programming. In the previous section, the "hello" program was compiled <strong>with</strong> default<br />

compile and link options. When debugging an application, it is useful to refer to the symbolic<br />

names of routines and variables. It is also convenient to debug at the source line level rather<br />

than the machine language level. To do this, we must direct both the compiler and linker to<br />

include additional debugging information in the object and executable files. Using the WCL<br />

8 Debugging the Sample <strong>DOS</strong> Application

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!