Rule 19.15 #include ssyntax, bad name

6.19 Preprocessing Directives

Moderators: misra-c, david ward

Post Reply
mshearer123
Posts: 14
Joined: Thu Feb 18, 2010 11:28 am
Company: TME

Rule 19.15 #include ssyntax, bad name

Post by mshearer123 » Tue Mar 02, 2010 3:54 pm

Hi,

My header files all include #ifndef / #define 's to stop them being included twice, however apparently the name is bad.

i have things like
#ifndef __DMA_h
#define __DMA_h
#endif


and

#ifndef __flash_h
#define __flash_h
#endif

Also changing to the following gives the same error

#ifndef flash_h
#define flash_h
#endif

any help would be great,

Matt

William Forbes
Posts: 29
Joined: Wed Dec 17, 2008 9:48 pm
Company: TRW Automotive

Re: Rule 19.15 #include ssyntax, bad name

Post by William Forbes » Tue Mar 02, 2010 10:16 pm

It may be useful to be more specific about the error and what tool reported the error.
I have a feeling that your checker may be broken as the code looks ok to me.

mshearer123
Posts: 14
Joined: Thu Feb 18, 2010 11:28 am
Company: TME

Re: Rule 19.15 #include ssyntax, bad name

Post by mshearer123 » Wed Mar 03, 2010 8:40 am

Hi,
I am using IBM's logiscope

there error reported states

Code: Select all

 MISRA_19_15 : Header inclusion
Severity is Required
Description
When a translation unit contains a complex hierarchy of nested header files 
it can happen that a particular header file is included more than once. 
This can be, at best, a source of confusion. If it leads to multiple or 
conflicting definitions, the result can be undefined or erroneous behaviour.
Multiple inclusions of a header file can sometimes be avoided by careful design. 
If this is not possible, a mechanism must be in place to prevent the file contents 
from being included more than once. A com- mon approach is to associate a macro 
with each file; the macro is defined when the file is included for the first time 
and used subsequently when the file is included again to exclude the contents 
of the file. 
For example a file called "ahdr.h" might be structured as follows: 
#ifndef AHDR_H 
#define AHDR_H 
/* The following lines will be excluded by the 
preprocessor if the file is included more 
than once */ 

mshearer123
Posts: 14
Joined: Thu Feb 18, 2010 11:28 am
Company: TME

Re: Rule 19.15 #include ssyntax, bad name

Post by mshearer123 » Wed Mar 03, 2010 8:41 am

Hi,
I am using IBM's logiscope

there error reported states

Code: Select all

 MISRA_19_15 : Header inclusion
Severity is Required
Description
When a translation unit contains a complex hierarchy of nested header files 
it can happen that a particular header file is included more than once. 
This can be, at best, a source of confusion. If it leads to multiple or 
conflicting definitions, the result can be undefined or erroneous behaviour.
Multiple inclusions of a header file can sometimes be avoided by careful design. 
If this is not possible, a mechanism must be in place to prevent the file contents 
from being included more than once. A com- mon approach is to associate a macro 
with each file; the macro is defined when the file is included for the first time 
and used subsequently when the file is included again to exclude the contents 
of the file. 
For example a file called "ahdr.h" might be structured as follows: 
#ifndef AHDR_H 
#define AHDR_H 
/* The following lines will be excluded by the 
preprocessor if the file is included more 
than once */ 
you could well be right about the tool not being set up correctly

misra-c
Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 19.15 #include ssyntax, bad name

Post by misra-c » Wed Mar 10, 2010 11:15 am

The code appears to be correct so it would be worth checking your tool configuration. If you have access to a different tool, you could try running your code through that too.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.19 Preprocessing Directives”