Modular C
Modular C

Modular C proposes a consistent naming convention to traditional C that is meant to cope with modularity and encapsulation. As a tool it is mainly based on textual rewriting source to source, with features that are orthogonal to those of C's preprocessing phase.

Modular C implements a handful of directives and a naming scheme that transform traditional translation units into modules. The add-on to the C language is minimal since we only add one feature, composed identifiers, to the core language.

Our modules can import other modules as long as the import relation remains acyclic and a module can refer to its own identifiers and those of the imported modules through freely chosen abbreviations.

Other than traditional C include, our import directive ensures complete encapsulation between modules.

The abbreviation scheme allows to seamlessly replace an imported module by another one with equivalent interface.

In addition to the export of symbols, we provide parameterized code injection through the import of snippets. This implements a mechanism that allows for code reuse, similar to X~macros or templates. Additional features of our proposal are a simple dynamic module initialization scheme, a structured approach to the C library and a migration path for existing software projects.

You can find a more detailed description of the approach in a research report on HAL. The software is open source and can be found on Inria's source forge