ABSTRACT
There are many things one can do wrong when using the C pre-processor's #ifdef statements. Such statements are often used to distinguish between hardware variants or operating system variants in the C code and when not used carefully, the C code easily becomes a mess of #ifdef cascades. This paper addresses this issue and provides best practices in form of patterns on how to organize variants in C code and on how to get rid of #ifdef statements.
- Flemming Bunzel. 2013. Hardware-abstraction of an open source real-time Ethernet stack - Design, realisation and evaluation.Google Scholar
- Brian Hook. 2005. Write Portable Code: An Introduction to Developing Software for Multiple Platforms. No Starch Press.Google Scholar
- Didier Malenfant. 2000. Writing Portable Code. In GDC.Google Scholar
- Robert C. Martin. 2008. Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall PTR.Google ScholarDigital Library
- Christopher Preschern. 2015. Idioms for Error Handling in C. In Proceedings of the 20th European Conference on Pattern Languages of Programming (EuroPLoP).Google ScholarDigital Library
- Christopher Preschern. 2016. API Patterns in C. In Proceedings of the 21st European Conference on Pattern Languages of Programming (EuroPLoP).Google ScholarDigital Library
- Christopher Preschern. 2017. Patterns for C Iterator Interfaces. In Proceedings of the 22nd European Conference on Pattern Languages of Programming (EuroPLoP).Google ScholarDigital Library
- Christopher Preschern. 2018. C Patterns on Objects and their Lifetime. In Proceedings of the 23rd European Conference on Pattern Languages of Programming (EuroPLoP).Google Scholar
- Christopher Preschern. 2018. Patterns for Returning Data from C Functions. In Proceedings of the 23rd European Conference on Pattern Languages of Programming (EuroPLoP).Google Scholar
- Christopher Preschern. 2019. Patterns for Returning Error Information in C. In Proceedings of the 24th European Conference on Pattern Languages of Programming (EuroPLoP).Google ScholarDigital Library
- Henry Spencer and Geoff Collyer. 1992. #ifdef Considered Harmful, or Portability Experience With C News. In Proceedings of the 1992 USENIX Conference.Google Scholar
Index Terms
- Patterns to escape the #ifdef hell
Recommendations
Memories of bug fixes
SIGSOFT '06/FSE-14: Proceedings of the 14th ACM SIGSOFT international symposium on Foundations of software engineeringThe change history of a software project contains a rich collection of code changes that record previous development experience. Changes that fix bugs are especially interesting, since they record both the old buggy code and the new fixed code. This ...
Towards the Definition of Patterns and Code Smells for Multi-language Systems
EuroPLoP '20: Proceedings of the European Conference on Pattern Languages of Programs 2020Developers often combine multiple programming languages to build large-scale applications. They choose programming languages properly for their tasks at hand instead of solving all of their problems with a single language. Foreign Functions Interface ...
Comments