Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1915

Preprocessor directives should not be indented

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Message:
      Remove the whitespace before the "#" character.
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Legacy Key:
      PPDirectiveIndentation
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • PC-Lint:
      556, 1556

      Description

      Indenting preprocessor directives reduces the code readability, because it make preprocessor directives harder to spot.

      Noncompliant Code Example

      void optimal()
      {
        #if INTEL             /* Noncompliant - hard to spot */
        specificIntelStuff();
        #endif                /* Noncompliant - hard to spot */
      }
      

      Compliant Solution

      void optimal()
      {
      #if INTEL               /* Compliant */
        specificIntelStuff();
      #endif                  /* Compliant */
      }
      

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4381 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: