Overview

 A Software Product Line (SPL) is a set of products developed from reusable assets. These products share a common platform and we can customize them for specific customers. In an SPL, developers use the concept of features. They are the semantic units by which we can differentiate products. In C programming, we can implement features by mapping them to preprocessor directives, such as #ifdef and#endif. In this context, although there are tools to deal with C preprocessors and SPLs, they are not integrated, which hinders their usage in product line development. In this paper, we propose a tool that provides an integrated environment based on the Eclipse platform to support the development of preprocessor-based SPLs in C. Thus, developers can create feature models, analyze SPL statistics, and generate SPL products automatically after checking for the absence of invalid products. 

Developers use the C Preprocessor (CPP) to handle portability and variability in program families of different sizes and domains. However, despite the widely use of the CPP in practice, it is often criticized due to its negative impact on code quality and maintainability, tool development, and its error-prone characteristics. In particular, developers aggravate these problems when using incomplete annotations, i.e., directives encompassing only parts of syntactical units. In a previous work, we performed an empirical study on 41 C program family releases and found that almost 93% of syntax errors occur in incomplete annotations. There are some refactorings to remove incomplete annotations proposed in the literature. However, they clone code and increase Lines of Code (LOC). To avoid incomplete annotations and their intrinsic problems, in this article we propose a catalogue of refactorings that converts incomplete annotations into complete ones without cloning code. We implement an Eclipse plug-in to help developers applying our refactorings automatically. To evaluate our catalogue, we performed a study to analyze questions related to code cloning, LOC, and number of directives. To answer our research questions, we analyze releases of 12 C program families of different domains ranging from 4.9 thousand to 1.5 million LOC. Our results show that our refactorings can remove all incomplete annotations without cloning code, and increasing only in 0.04% the LOC and in 2.10% the number of directives.