Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

MISRA.INCL.BAD

Non-standard include directive.

MISRA C 2012 Rule 20.3: The #include directive shall be followed by either a <filename> or "filename" sequence

C90 [Undefined 48], C99 [Undefined 85]

Category: Analysis

Analysis: Decidable, Single Translation Unit

Applies to: C90, C99

Amplification

This rule applies after macro replacement has been performed.

Rationale

The behaviour is undefined if a #include directive does not use one of the following forms:
  • #include <filename>
  • #include "filename"

Example

#include "filename.h"                  /* Compliant     */ 
#include <filename.h>                  /* Compliant     */ 
#include another.h                     /* Non-compliant */

#define HEADER "filename.h" 
#include HEADER                        /* Compliant     */ 
#define FILENAME file2.h
#include FILENAME                      /* Non-compliant */

#define BASE "base" 
#define EXT ".ext" 
#include BASE EXT                      /* Non-compliant - strings are concatenated
                                        *                 after preprocessing      */

#include "./include/cpu.h"             /* Compliant - filename may include a path  */

MISRA-C 2004 Rule 19.3 (required): The ''#include'' directive shall be followed by either a ''<filename>'' or -'filename''" sequence.

Non-standard include directive.

[Undefined 48]

Example

For example, the following are allowed.

#include "filename.h"
#include <filename.h>
#define FILE_A "filename.h"
#include FILE_A

MISRA-C++ 2008 Rule 16-2-6 (required): The ''#include'' directive shall be followed by either a ''<filename>'' or "filename" sequence.

[Undefined 16.2(4)]

Rationale

These are the only forms for the #include directive permitted by ISO/IEC 14882:2003 [1].

Example

#include "filename.h"         // Compliant
#include <filename.h>         // Compliant
#define HEADER "filename.h"   // Non-compliant with Rule 16—2—2
#include HEADER               // Compliant
#include another.h            // Non-compliant