CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MISRA rule violation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
micsch



Joined: 06 Dec 2011
Posts: 4

View user's profile Send private message

MISRA rule violation
PostPosted: Tue Dec 06, 2011 1:21 am     Reply with quote

Hi,

I get a rule violation by MISRA (2004) when I use Pre-Processor directives like #FUSES, #device , #int_TIMER0 and so on.

The rule is:
[ MISRA 19.16 ] Preprocessing directives shall be syntactically meaningful even when excluded by the preprocessor.


How can I handle this?
Any help would be greatful.

Code:

//Configuration uC in Headerfile
#device adc=8                                                   /*Aufloesung AD-Wandler in Bit                    */
#FUSES NOWDT                                                    /*No Watch Dog Timer                              */
#FUSES INTRC_IO                                                 /*Internal RC Osc                                 */
#FUSES PUT                                                      /*Power Up Timer                                  */
#FUSES NOPROTECT                                                /*Code protected from reads                       */
#FUSES MCLR                                                     /*Master Clear pin enabled                        */
#FUSES NOCPD                                                    /*No EE protection                                */
#FUSES BROWNOUT                                                 /*brownout reset                                  */
#FUSES NOIESO                                                   /*Internal External Switch Over mode disabled     */
#FUSES NOFCMEN                                                  /*Fail-safe clock monitor disabled                */
#FUSES NODEBUG                                                  /*No Debug mode for ICD                           */
#use delay(clock=2000000)                                       /*System-Clock = Oszillator-Clock:4 = 500'000 kHz */
#use i2c(master, sda=PIN_C7, scl=PIN_C6, slow)                  /* Configure Device as Master                     */


and by the two ISR in the C-file:

Code:

   #int_TIMER0
void timer0Isr( void )                 
{
}

   #int_TIMER1
void timer1Isr( void )                                       
{
}
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Dec 06, 2011 2:33 am     Reply with quote

Tricky...

It may be complaining at the comments after the directives. It may be worried about the white spaces before, which are not allowed in strict C. It may be expecting only a well-defined set of directives, such as #define, #ifdef #else and other conventionally used preprocessor directives. The fact is that to CCS C, but not a generic C as possibly is expected by your MISRA test suite, these are syntactically meaningful. I'm not totally sure I know what the MISRA standard means by "exclusion by the preprocessor". Given, also that CCS, like so many other C compiler implementations these days integrates pre-processor functionality with the compiler, doing it all effectively in one pass.

How you deal with this is another matter. You have to take a view as to treat this as a warning, and work round it.

RF Developer
micsch



Joined: 06 Dec 2011
Posts: 4

View user's profile Send private message

PostPosted: Tue Dec 06, 2011 3:18 am     Reply with quote

Probably you are right. It seems that MISRA-rule does not know these directives and generates the violation. So there is not a possibility to fix it.
I will ask this in MISRA.org.uk, maybe they know what to do.

Many thanks.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Dec 06, 2011 5:32 am     Reply with quote

This is another example that's covered by what Ttelmah pointed out

Quote:

"It is recognized that it may be necessary to raise deviations (as described in section 5.3.2) to permit certain language extensions, for example to support hardware specific features."

Configuring the fuses, just as with the ADC, is such a feature.

RF Developer
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group