Conditional Compilation is Dead, Long Live Conditional Compilation!

Highly-configurable systems written in C form our most critical computing infrastructure. The preprocessor is integral to C, because conditional compilation enables such systems to produce efficient object code. However, the preprocessor makes code harder to reason about for both humans and tools. Previous approaches to this challenge developed new program analyses for unpreprocessed source code or developed new languages and constructs to replace the preprocessor. But having special-purpose analyses means maintaining a new toolchain, while new languages face adoption challenges and do not help with existing software. We propose the best of worlds: eliminate the preprocessor but preserve its benefits. Our design replaces preprocessor usage with C itself, augmented with syntax-preserving, backwards-compatible dependent types. We discuss automated conditional compilation to replicate preprocessor performance. Our approach opens new directions for research into new compiler optimizations, dependent types for configurable software, and automated translation away from preprocessor use.

[1]  Robert Grimm,et al.  SuperC: parsing all of C by taming the preprocessor , 2012, PLDI.

[2]  Christian Kästner,et al.  Virtual Separation of Concerns: Toward Preprocessors 2.0 , 2010, it Inf. Technol..

[3]  Per Martin-Löf,et al.  Constructive mathematics and computer programming , 1984 .

[4]  Elmar Jürgens,et al.  Analyzing the Effect of Preprocessor Annotations on Code Clones , 2011, 2011 IEEE 11th International Working Conference on Source Code Analysis and Manipulation.

[5]  Ralph E. Johnson,et al.  Analyzing multiple configurations of a C program , 2005, 21st IEEE International Conference on Software Maintenance (ICSM'05).

[6]  Christian Kästner,et al.  Faster variational execution with transparent bytecode transformation , 2018, Proc. ACM Program. Lang..

[7]  Claus Brabrand,et al.  Variability through the Eyes of the Programmer , 2017, 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC).

[8]  Martin Erwig,et al.  #ifdef confirmed harmful: Promoting understandable software variation , 2011, 2011 IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC).

[9]  Leo A. Meyerovich,et al.  Socio-PLT: principles for programming language adoption , 2012, Onward! 2012.

[10]  Martin Erwig,et al.  Extending Type Inference to Variational Programs , 2014, ACM Trans. Program. Lang. Syst..

[11]  Martin Erwig,et al.  A Calculus for Variational Programming , 2016, ECOOP.

[12]  Gunter Saake,et al.  Feature-Oriented Software Product Lines , 2013, Springer Berlin Heidelberg.

[13]  Márcio Ribeiro,et al.  The Love/Hate Relationship with the C Preprocessor: An Interview Study , 2015, ECOOP.

[14]  Sebastian Erdweg,et al.  A variability-aware module system , 2012, OOPSLA '12.

[15]  Herb Sutter,et al.  C++ coding standards , 2004 .

[16]  Mira Mezini,et al.  SPLLIFT: statically analyzing software product lines in minutes instead of years , 2013, Software Engineering.

[17]  Sebastian Erdweg,et al.  Variability-aware parsing in the presence of lexical macros and conditional compilation , 2011, OOPSLA '11.

[18]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[19]  Eric A. Brewer,et al.  ASTEC: a new approach to refactoring C , 2005, ESEC/FSE-13.

[20]  Hung Viet Nguyen,et al.  Exploring variability-aware execution for testing plugin-based web applications , 2014, ICSE.

[21]  Sven Apel,et al.  Variational Data Structures: Exploring Tradeoffs in Computing with Variability , 2014, Onward!.

[22]  George C. Necula,et al.  Dependent Types for Low-Level Programming , 2007, ESOP.

[23]  Claus Brabrand,et al.  Effective Analysis of C Programs by Rewriting Variability , 2017, Art Sci. Eng. Program..

[24]  Sven Apel,et al.  Scalable analysis of variable software , 2013, ESEC/FSE 2013.