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

"#include_next" should not be used

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this use of "#include_next".
    • Highlighting:
      Hide

      #include_next

      Show
      #include_next
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++, Objective-C
    • Irrelevant for Languages:
      ABAP, C#, Cobol, CSS, Flex, HTML, Java, JavaScript, PHP, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      #include_next is a gcc-specific language extension that alters the search path for the specified header file by starting the search from the header file directory after the one in which the directive was encountered. It also ignores the distinction between "file" and <file>. It is typically used when you have two (probably related) header files with the same name, although there is nothing in the extension to enforce or limit the use to same-name files.

      Use of this extension can be tricky to get right, and is almost never justified. Instead, you should use an absolute path in the #include statement or rename one of the files.

      Noncompliant Code Example

      #include_next "foo.h" // Noncompliant
      

      Compliant Solution

      #include "/usr/local/include/foo.h"
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jeanchristophe.collet Jean-Christophe Collet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: