CITS2002 Systems Programming  
prev
next CITS2002 CITS2002 schedule  

Developing larger C programs in multiple files

Just as C programs should be divided into a number of functions (we often say the program is modularized), larger C programs should be divided into multiple source files.

The motivations for using multiple source files are:

  • each file (often containing multiple related functions) may perform (roughly) a single role,

  • the number of unnecessary global variables can be significantly reduced,

  • we may easily edit the multiple files in separate windows or tabs,

  • large projects may be undertaken by multiple people each working on a subset of the files,

  • each file may be separately compiled into a distinct object file,

  • small changes to one source file do not require all other source files to be recompiled.

All object files are then linked to form a single executable program.

 


CITS2002 Systems Programming, Lecture 17, p3, 26th September 2023.