CS010 Practice 8

Preprocessor Commands, Make

 
  1. Add debugging statements to some of your hangman functions. Use conditional compilation so that they are only executed if debugging is set at compile time.
  2. Run the compiler on the file you created yesterday that contains just the two functions I gave you. Assuming that file is called utils.c, you would use the following command to run just the preprocessor:
    gcc -o utils.E -E utils.c

    This will run just the preprocessor. It will not generate any object code. Now, take a look at the generated file utils.E. Compare this generated file to your original C file. You should be able to see your original C code (at the end) as well as the prototypes that came from the .h files. Your .h file should be included as well as sys/time.h and whatever else you may have included.

  3. Create a makefile that can be used to build the version of the hangman program that uses multiple files. Delete your existing executable and .o files. Run make to rebuild the executable. You should be able to do it with a single command line.
  4. Remove the #define in your source code that controls debugging. Instead, change the value of your CFLAGS variable in your makefile to turn debugging on and off.