Preprocessor Lines is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Preprocessor Lines
API ID: CountLinePreprocessorLanguages: Ada, C#, C++
Targets: Architectures, Classes, Files, Functions, Packages, Project, Subprograms
Number of preprocessor lines.
Lines containing a preprocessor directive, such as #include, #define, #if/#ifdef, and #endif. These lines are always considered active, regardless of whether the code they guard is active.
For example:
void SayHello::printHello() {
switch (i) {
case 0:
cout << "Hello World" << endl;
case 1:
cout << "HELLO WORLD!" << endl;
default: // a comment here
for (int m = 0; m < j; m++);
cout << "hello world" << endl;
}
#ifdef A_VERY_NICE_VARIABLE
cout << "Inactive Line" << endl; // Inactive
#endif
}
#ifdef A_VERY_NICE_VARIABLE and #endif (lines 21 and 24) are the only preprocessor lines, giving CountLinePreprocessor = 2.
See Inactive Lines for the lines on the false side of a directive like these.
- Ada: Project, File, Type, Entry, Function, Package, Procedure, Protected, Task
- C#: Project, File, Class, Method
- C++: Project, File, Class, Struct, Union, Function
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Show line count metrics" option.
- For projects and architectures, this metric is enabled from "Project Configuration/Metrics/Projects and Architectures" with the "Show default summary metrics" option.