Defining and Enforcing C's Module System. Saurabh Srivastava, Michael Hicks, Jeffrey S. Foster, and Bhargav Kanagal. Technical Report CS-4816, Department of Computer Science, University of Maryland, July 2006.

Programming language module systems are an important tool for managing the complexity of large software systems. The C programming language is used to build many such systems, yet it lacks a proper module system. Instead, C programmers typically follow a convention that treats .h header files as interfaces and .c source files as modules. This convention can be effective, but there are many subtleties in using it correctly, and the compiler and linker provide no enforcement mechanism. As a result, misuse of the convention can lead to hard-to-find bugs, can make reasoning about code in isolation more difficult, and can complicate future code maintenance.

This paper presents CMod, a module system for C that ensures abstraction via information hiding and type-safe separate compilation. Our approach is to identify and enforce the circumstances under which C's current modular programming convention is sound. The result is four rules that, using an operational semantics for an idealized preprocessor, we have proven are sufficient to guarantee the desired modularity properties. We have implemented CMod for the full C language and applied it to a number of benchmarks. We found that most of the time legacy programs obey CMod's rules, or can be made to with minimal effort, and rule violations often result in type errors or brittle code. Thus CMod brings the benefits of modular programming to C while still supporting legacy systems.

http | .pdf ]

  title = {Defining and Enforcing {C}'s Module System},
  author = {Saurabh Srivastava and Michael Hicks and Jeffrey S. Foster and Bhargav Kanagal},
  institution = {Department of Computer Science, University of Maryland},
  number = {CS-4816},
  month = {July},
  year = 2006,
  http = {}

This file was generated by bibtex2html 1.99.