Previous Table of Contents Next


Putting It All Together

The actual commands to build the compression and expansion programs will differ depending on which compiler and operating system you are using. Assuming you name the compression program HUFF-C and the expansion program HUFF-E, here are the command lines to compile the programs with various compilers:

     Microsoft C:  cl /W3 /Za /FeHUFF-C MAIN-C.C HUFF.C BITIO.C ERRHAND.C
                   cl /W3 /Za /FeHUFF-E MAIN-E.C HUFF.C BITIO.C ERRHAND.C
     Borland C++:  bcc -Ax -w -eHUFF-C MAIN-C.C HUFF.C BITIO.C ERRHAND.C
                   bcc -Ax -w -eHUFF-E MAIN-E.C HUFF.C BITIO.C ERRHAND.C
     UNIX pcc:  cc -ohuff-c main-c.c huff.c bitio.c errhand.c
                cc -ohuff-e main-e.c huff.c bitio.c errhand.c

Remember that ANSI-compatible C compilers must have their extensions turned off on the command line to enable the __STDC__ macro. The __STDC__macro is necessary to turn on the ANSI prototypes. If you don’t want to continually have to add this unfamiliar command-line switch when you compile, simply strip out the “#ifdef __STDC__” line and always pull in the ANSI C prototypes. The only reason for doing this is to have code that will compile cleanly on K&R compilers. If you aren’t using a K&R compiler, keeping in the K&R prototypes is of dubious value.

The module ERRHAND.C needs the __UNIX__ definition in order to use old-style variable arguments. Fully compliant ANSI C compilers may not have to turn this option on. If you are going to only be using your source code on your UNIX system, it would probably be simpler to put a “#define__UNIX__” in your ERRHAND.C file.

Performance

Order 0 Huffman coding is not going to take any prizes for compression ratios. But it does fairly well in terms of program size, memory requirements, and processing speed. To see how HUFF.C does overall, see the scorecards in Appendix A.


Previous Table of Contents Next