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

"#include" directives should be followed by either <filename> or "filename" sequences

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      PPBadIncludeForm
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • MISRA C 2004:
      19.3
    • MISRA C 2012:
      20.3
    • MISRA C++ 2008:
      16-2-6
    • PC-Lint:
      12, 1012, 9086

      Description

      These are the only forms for the #include directive permitted by the standard. The behavior is undefined when other forms are used.

      Noncompliant Code Example

      #include filename.h        // Noncompliant
      

      Compliant Solution

      #include "filename.h"        // Compliant
      #include <filename.h>
      
      #define HEADER "filename.h"
      #include HEADER
      

      See

      • MISRA C:2004, 19.3 - The #include directive shall be followed by either a <filename> or "filename" sequence.
      • MISRA C++:2008, 16-2-6 - The #include directive shall be followed by either a <filename> or "filename" sequence.
      • MISRA C:2012, 20.3 - The #include directive shall be followed by either a <filename> or "filename" sequence

        Attachments

          Issue Links

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

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: