Skip to Main content Skip to Navigation

Modular C

Jens Gustedt 1
1 CAMUS - Compilation pour les Architectures MUlti-coeurS
Inria Nancy - Grand Est, ICube - Laboratoire des sciences de l'ingénieur, de l'informatique et de l'imagerie
Abstract : We propose an extension to the C standard called Modular C. It consists in the addition of a handful of directives and a naming scheme transforming traditional translation units into modules. The change 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's #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. The whole approach is validated by a formal description of a translation procedure from Modular C to common C and a proof of the correctness of that procedure. Thereby we are able to show that the class of stable programs can effectively be expressed in Modular C and that the gain of modularity is not thwarted by a loss of expressiveness. Here stable programs are those that do not use extensive C macro facilities that manipulate identifiers. Our approach is implemented and used successfully and efficiently in several projects. Interfaces can easily be provided both ways, to interface existing projects for Modular C or to interface Modular C libraries with other programming languages
Keywords : modularity
Complete list of metadata

Cited literature [15 references]  Display  Hide  Download
Contributor : Jens Gustedt Connect in order to contact the contributor
Submitted on : Tuesday, June 12, 2018 - 1:42:02 PM
Last modification on : Thursday, February 7, 2019 - 4:19:19 PM
Long-term archiving on: : Friday, September 14, 2018 - 12:12:06 AM


Files produced by the author(s)


  • HAL Id : hal-01169491, version 4


Jens Gustedt. Modular C. [Research Report] RR-8751, INRIA. 2015. ⟨hal-01169491v4⟩



Record views


Files downloads