CITS4407 Open Source Tools and Scripting  
next CITS4407 help4407 CITS4407 schedule  

Developing larger programs in multiple files

Just as 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 is minimized,

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

  • 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.


CITS4407 Open Source Tools and Scripting, Week 9, p1.