Overview
Documentation
Source Code
Results
People

Overview

CMod is a tool written to enforce a modular programming style in C code, to ensure that modules, when linked together, yield a type correct program.

C syntax does not provide direct support for modules. But over time, programmers have developed a discipline of modular programming which treats .c files as module implementations and .h files as interfaces. However, without proper enforcement (of the requirements of a module system), mistakes can be made which will not be reported by a normal C compiler. In particular, one module can declare that it requires some symbol of type T1, but in the module defining the symbol it actually has type T2. This problem is compounded and obfuscated by the extensive use of preprocessor directives which is common in large C programs. These mistakes can lead to confusing errors that manifest themselves at runtime and are hard to track down.

The reason this problem exists in C is because the language has only an informal notion of an external interface: the .h file. CMod provides a way to treat .h as more formal interfaces. In particular, it enforces three rules as to how .h files should and should not be used; if the rules are followed, checked by CMod at compile-time and link-time, then the final program is likely to be type correct. In addition to this benefit, it is widely recognized that modular code is easier to maintain, easier to extend and more readable.

Documentation

CMod is designed to be non-intrusive. To get CMod to check code that you develop, simply change your search path to include the CMod wrappers before your actual compiler and linker. The CMod wrappers will do the consistency check before passing your code onto the linker(compiler). If inconsistencies are found, warnings will be dumped to stdout and detailed diagnostic data will be stored in log files.

Usage Manual: Papers: Detailed Technical Reports:

Source Code

CMod is
Open Source / Free Software, and is freely available under the GNU General Public License. It is mostly written in OCaml and interfaces with cpplib (provided by GNU gcc) for preprocessing needs.

Building and Using CMod: For the most up to date instructions consult the manual.pdf

Download the sources below. Extract and cd into src/ directory. Run make to build the tool. The binaries are installed in the bin/ directory.

CMod requires a compiler that supports separate compilation and linking (e.g. gcc, gcc -c and gcc -o). If the project being checked for consistency requires any other standard tools for successful compilation then they should be available and in the path as well; e.g. gmake, ar etc.

A good codebase to get you started on seeing how the tool runs is vsftpd. Detailed instructions on how to incorporate CMod into the build process and on how to interpret the log files are provided in the README in the distribution.

Builds

CMod is under heavy development. The builds are numbered as v#.#-b#### where #.# is the version and #### is the subversion revision number for that build.

Bug Reports

Highly appreciated. Direct all bug reports to .

People

CMod is being developed at the University of Maryland's PL group by: