[previous] MISRA C:2012  Dir-4.10:  (Required) [next] Precautions shall be taken in order to prevent the contents of a header file being included more then once

Example Code:


#include "misra.h"
#include "m3cmex.h"

#include "dir-0410-ok1.h"
#include "dir-0410-ok2.h"
#include "dir-0410-bad.h"

extern int16_t dir_0410( void )
{
   return 1;
}

Example Code:


#ifndef DIR_0410_OK1_H

       /* Comments and whitespace */

#define DIR_0410_OK1_H

#include "misra.h"
#include "misra.h"

typedef int16_t ok1;

#endif

Example Code:


#ifdef DIR_0410_OK2_H
       /* Comments and whitespace */
#error Header already included
       /* Comments and whitespace */
#else
       /* Comments and whitespace */

#define DIR_0410_OK2_H

#include "misra.h"

typedef int16_t ok2;

#endif

Example Code:


#include "misra.h"                              /* 0883 */

typedef int16_t bad1;

#ifndef DIR_0410_BAD_H
#define DIR_0410_BAD_H

#include "misra.h"

typedef int32_t bad2;

#endif


QAC messages that encompass this guideline:

0883 Include file code is not protected against repeated inclusion



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents