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 ]

@TECHREPORT{srivastava06cmodtr,
  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 = {http://www.cs.umd.edu/~saurabhs/CMod/}
}

This file has been generated by bibtex2html 1.69