scitools.com

← Metric catalog

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: CountLinePreprocessor
Languages: 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.


Targets By Language: Configuration: