Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/1960275.1960299acmconferencesArticle/Chapter ViewAbstractPublication PagesmodularityConference Proceedingsconference-collections
research-article

Analyzing the discipline of preprocessor annotations in 30 million lines of C code

Published: 21 March 2011 Publication History

Abstract

The C preprocessor cpp is a widely used tool for implementing variable software. It enables programmers to express variable code (which may even crosscut the entire implementation) with conditional compilation. The C preprocessor relies on simple text processing and is independent of the host language (C, C++, Java, and so on). Language-independent text processing is powerful and expressive - programmers can make all kinds of annotations in the form of #ifdefs - but can render unpreprocessed code difficult to process automatically by tools, such as refactoring, concern management, and variability-aware type checking. We distinguish between disciplined annotations, which align with the underlying source-code structure, and undisciplined annotations, which do not align with the structure and hence complicate tool development. This distinction raises the question of how frequently programmers use undisciplined annotations and whether it is feasible to change them to disciplined annotations to simplify tool development and to enable programmers to use a wide variety of tools in the first place. By means of an analysis of 40 medium-sized to large-sized C programs, we show empirically that programmers use cpp mostly in a disciplined way: about 84% of all annotations respect the underlying source-code structure. Furthermore, we analyze the remaining undisciplined annotations, identify patterns, and discuss how to transform them into a disciplined form.

References

[1]
B. Adams, W. De Meuter, H. Tromp, and A. Hassan. Can we Refactor Conditional Compilation into Aspects? In Proc. of the Int'l Conf. on Aspect-Oriented Software Development (AOSD), pages 243--254. ACM Press, 2009.
[2]
D. Atkins, T. Ball, T. Graves, and A. Mockus. Using Version Control Data to Evaluate the Impact of Software Tools: A Case Study of the Version Editor. IEEE Trans. on Softw. Eng. (TSE), 28(7):625--637, 2002.
[3]
L. Aversano, L. Di Penta, and I. Baxter. Handling Preprocessor-Conditioned Declarations. In Proc. of the Int'l Workshop on Source Code Analysis and Manipulation (SCAM), pages 83--92. IEEE CS, 2002.
[4]
I. Baxter and M. Mehlich. Preprocessor Conditional Removal by Simple Partial Evaluation. In Proc. of the Working Conf. on Reverse Engineering (WCRE), pages 281--290. IEEE CS, 2001.
[5]
M. Bruntink, A. van Deursen, M. D'Hondt, and T. Tourwé. Simple Crosscutting Concerns Are Not So Simple: Analysing Variability in Large-Scale Idioms-Based Implementations. In Proc. of the Int'l Conf. on Aspect-Oriented Software Development (AOSD), pages 199--211. ACM Press, 2007.
[6]
M. Bruntink, A. van Deursen, and T. Tourwé. Isolating Idiomatic Crosscutting Concerns. In Proc. of the Int'l Conf. on Software Maintenance (ICSM), pages 37--46. IEEE CS, 2005.
[7]
A. Classen, P. Heymans, P.-Y. Schobbens, A. Legay, and J.-F. Raskin. Model Checking Lots of Systems: Efficient Verification of Temporal Properties in Software Product Lines. In Proc. of the Int'l Conf. on Software Engineering (ICSE), pages 335--344. ACM Press, 2010.
[8]
M. Ernst, G. Badros, and D. Notkin. An Empirical Analysis of C Preprocessor Use. IEEE Trans. on Softw. Eng. (TSE), 28(12):1146--1170, 2002.
[9]
M. Erwig and E. Walkingshaw. The Choice Calculus: A Representation for Software Variation. ACM Trans. on Softw. Eng. and Meth. (TOSEM), 2010. to appear.
[10]
J.-M. Favre. The CPP Paradox. In Proc. of the Europ. Workshop on Software Maintenance, 1995. http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.9464.
[11]
J.-M. Favre. Understanding-In-The-Large. In Proc. of the Int'l Workshop on Program Comprehension (IWPC), pages 29--38. IEEE CS, 1997.
[12]
A. Garrido. Program Refactoring in the Presence of Preprocessor Directives. PhD thesis, University of Illinois, 2005.
[13]
A. Garrido and R. Johnson. Refactoring C with Conditional Compilation. In Proc. of the Int'l Conf. on Automated Software Engineering (ASE), pages 323--326. IEEE CS, 2003.
[14]
A. Garrido and R. Johnson. Analyzing Multiple Configurations of a C Program. In Proc. of the Int'l Conf. on Software Maintenance (ICSM), pages 379--388. IEEE CS, 2005.
[15]
W. Griswold, J. Yuan, and Y. Kato. Exploiting the Map Metaphor in a Tool for Software Evolution. In Proc. of the Int'l Conf. on Software Engineering (ICSE), pages 265--274. IEEE CS, 2001.
[16]
F. Heidenreich, I. Savga, and C. Wende. On Controlled Visualizations in Software Product Line Engineering. In Proc. of the SPLC Workshop on Visualization in Software Product Line Engineering (ViSPLE), pages 303--313. Lero International Science Centre, 2008.
[17]
D. Janzen and K. De Volder. Programming with Crosscutting Effective Views. In Proc. of the Europ. Conf. on Object-Oriented Programming (ECOOP), pages 195--218. Springer-Verlag, 2004.
[18]
E. Jürgens, F. Deissenböck, B. Hummel, and S. Wagner. Do Code Clones Matter? In Proc. of the Int'l Conf. on Software Engineering (ICSE), pages 485--495. IEEE CS, 2009.
[19]
C. Kapser and M. Godfrey. "Cloning Considered Harmful" Considered Harmful. Empirical Software Engineering, 13(6):645--692, 2008.
[20]
C. Kästner and S. Apel. Type-Checking Software Product Lines - A Formal Approach. In Proc. of the Int'l Conf. on Automated Software Engineering (ASE), pages 258--267. IEEE CS, 2008.
[21]
C. Kästner and S. Apel. Virtual Separation of Concerns - A Second Chance for Preprocessors. Journal of Object Technology (JOT), 8(6):59--78, 2009.
[22]
C. Kästner, S. Apel, and M. Kuhlemann. A Model of Refactoring Physically and Virtually Separated Features. In Proc. of the Int'l Conf. on Generative Programming and Component Engineering (GPCE), pages 157--166. ACM Press, 2009.
[23]
C. Kästner, S. Apel, S. Trujillo, M. Kuhlemann, and D. Batory. Guaranteeing Syntactic Correctness for all Product Line Variants: A Language-Independent Approach. In Proc. of the Int'l Conf. Objects, Models, Components, Patterns (TOOLS Europe), pages 174--194. Springer-Verlag, 2009.
[24]
B. Kernighan and D. Ritchie. The C Programming Language. Prentice-Hall, 1988.
[25]
B. Leavenworth. Syntax Macros and Extented Translation. Communications of the ACM (CACM), 9(11):790--793, 1966.
[26]
J. Liebig, S. Apel, C. Lengauer, C. Kästner, and M. Schulze. An Analysis of the Variability in Forty Preprocessor-Based Software Product Lines. In Proc. of the Int'l Conf. on Software Engineering (ICSE), pages 105--114. ACM Press, 2010.
[27]
D. Lohmann, F. Scheler, R. Tartler, O. Spinczyk, and W. Schröder-Preikschat. A Quantitative Analysis of Aspects in the eCos Kernel. In Proc. of the EuroSys Conf., pages 191--204. ACM Press, 2006.
[28]
B. McCloskey and E. Brewer. ASTEC: A New Approach to Refactoring C. In Proc. of the Europ. Software Engineering Conf. and of the Int'l Symposium on Foundations of Software Engineering (ESEC/FSE), pages 21--30. ACM Press, 2005.
[29]
Y. Padioleau. Parsing C/C++ Code without Pre-processing. In Proc. of the Int'l Conf. on Compiler Construction (CC), pages 109--125. Springer-Verlag, 2009.
[30]
T. Pearse and P. Oman. Experiences Developing and Maintaining Software in a Multi-Platform Environment. In Proc. of the Int'l Conf. on Software Maintenance (ICSM), pages 270--277. IEEE CS, 1997.
[31]
H. Post and C. Sinz. Configuration Lifting: Verification meets Software Configuration. In Proc. of the Int'l Conf. on Automated Software Engineering (ASE), pages 347--350. IEEE CS, 2008.
[32]
A. Reynolds, M. Fiuczynski, and R. Grimm. On the Feasibility of an AOSD Approach to Linux Kernel Extensions. In Proc. of the AOSD Workshop on Aspects, Components, and Patterns for Infrastructure Software (ACP4IS), pages 1--7. ACM Press, 2008.
[33]
C. Roy and J. Coardy. A Survey on Software Clone Detection Research. Technical Report 2007-541, Queen's University at Kingston, 2007.
[34]
N. Singh, C. Gibbs, and Y. Coady. C-CLR: A Tool for Navigating Highly Configurable System Software. In Proc. of the AOSD Workshop on Aspects, Components, and Patterns for Infrastructure Software (ACP4IS), page 9. ACM Press, 2007.
[35]
H. Spencer and G. Collyer. #ifdef Considered Harmful, or Portability Experience with C News. In Proc. of the USENIX Technical Conf., pages 185--197. USENIX Association Berkeley, 1992.
[36]
D. Spinellis. Global Analysis and Transformations in Preprocessed Languages. IEEE Trans. on Softw. Eng. (TSE), 29(11):1019--1030, 2003.
[37]
L. Vidács, A. Beszédes, and T. Gyimóthy. Combining Preprocessor Slicing with C/C++ Language Slicing. Science of Computer Programming (SCP), 74(7):399--413, 2009.
[38]
M. Vittek. Refactoring Browser with Preprocessor. In Proc. of the Europ. Conf. on Software Maintenance and Reengineering (CSMR), pages 101--110. IEEE CS, 2003.
[39]
D. Weise and R. Crew. Programmable Syntax Macros. In Proc. of the Int'l Conf. on Programming Language Design and Implementation (PLDI), pages 156--165. ACM Press, 1993.

Cited By

View all
  • (2024)Exploring Influence of Feature Toggles on Code ComplexityProceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering10.1145/3661167.3661190(363-368)Online publication date: 18-Jun-2024
  • (2024)Should I Bother? Fast Patch Filtering for Statically-Configured Software VariantsProceedings of the 28th ACM International Systems and Software Product Line Conference10.1145/3646548.3672585(12-23)Online publication date: 2-Sep-2024
  • (2023)Evolutionary Feature Dependencies: Analyzing Feature Co-Changes in C Systems2023 IEEE 23rd International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM59687.2023.00019(84-95)Online publication date: 2-Oct-2023
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
AOSD '11: Proceedings of the tenth international conference on Aspect-oriented software development
March 2011
326 pages
ISBN:9781450306058
DOI:10.1145/1960275
  • General Chair:
  • Paulo Borba,
  • Program Chair:
  • Shigeru Chiba
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

  • Centro de Informatica - UFPE: Centro de Informatica - UFPE
  • CAPES: Coordençãao de Aperfeiçoamento de Pessoal de Nível Superior
  • CNPq: Conselho Nacional de Desenvolvimento Cientifico e Tecn
  • FINEP: Financiadora de Estudos e Projetos
  • PUC-Rio
  • FACEPE: Fundacao de Amparo a Ciencia e Tecnologia do Estado de Pernambuco

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 21 March 2011

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. conditional compilation
  2. crosscutting concerns
  3. ifdef
  4. preprocessor
  5. virtual separation of concerns

Qualifiers

  • Research-article

Conference

AOSD'11

Acceptance Rates

Overall Acceptance Rate 41 of 139 submissions, 29%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)18
  • Downloads (Last 6 weeks)5
Reflects downloads up to 28 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Exploring Influence of Feature Toggles on Code ComplexityProceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering10.1145/3661167.3661190(363-368)Online publication date: 18-Jun-2024
  • (2024)Should I Bother? Fast Patch Filtering for Statically-Configured Software VariantsProceedings of the 28th ACM International Systems and Software Product Line Conference10.1145/3646548.3672585(12-23)Online publication date: 2-Sep-2024
  • (2023)Evolutionary Feature Dependencies: Analyzing Feature Co-Changes in C Systems2023 IEEE 23rd International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM59687.2023.00019(84-95)Online publication date: 2-Oct-2023
  • (2023)Feature Toggle Usage Patterns: A Case Study on Google Chromium2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR)10.1109/MSR59073.2023.00032(142-147)Online publication date: May-2023
  • (2023)Variational satisfiability solving: efficiently solving lots of related SAT problemsEmpirical Software Engineering10.1007/s10664-022-10217-328:1Online publication date: 1-Jan-2023
  • (2022)Systematic Software Reuse with Automated Extraction and Composition for Clone-and-OwnHandbook of Re-Engineering Software Intensive Systems into Software Product Lines10.1007/978-3-031-11686-5_15(379-404)Online publication date: 5-Jul-2022
  • (2021)CppSigProceedings of the 11th Workshop on Programming Languages and Operating Systems10.1145/3477113.3487268(62-68)Online publication date: 25-Oct-2021
  • (2021)Feature trace recordingProceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3468264.3468531(1007-1020)Online publication date: 20-Aug-2021
  • (2021)A Study of Feature Scattering in the Linux KernelIEEE Transactions on Software Engineering10.1109/TSE.2018.288491147:1(146-164)Online publication date: 1-Jan-2021
  • (2021)Evaluating refactorings for disciplining #ifdef annotations: An eye tracking study with novicesEmpirical Software Engineering10.1007/s10664-021-10002-826:5Online publication date: 7-Jul-2021
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media