Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 19.16
#1
The syntax errors the rule talks about would any way be reflected as an sytax error by the compiler.

for example in
#defineNAME \"test\"

the complier would return an error.

So in effect the rule becomes redundant!
<t></t>
#2
The compiler does not produce an error if the syntax error is inside a condition compilation branch which are not \"selected\".

Example:

Code:
#define AAA 2

int foo(void)
{
   int x;

#ifndef AAA
   x = 1;
  rlhegsfldghsfdghlsfd
#else
   x = 0;
#endif
   return(x);
}

This code will not produce an error, because AAA is define and so, the syntax error is inside the exclued code.

In the MISRA example:

Code:
#define AAA 2

int foo(void)
{
   int x;

#ifndef AAA
   x = 1;
#else1
   x = 0;
#endif
   return(x);
}

If AAA is defined then all code after the #ifndef is ignored until a #else, #elif or #endif instruction. In the example, there is a syntax error on #else and so, if AAA is define all code between #ifndef and #endif will be exclued and the result code will be, without any error:

Code:
#define AAA 2

int foo(void)
{
   int x;

   return(x);
}

But the desired behavior was certainly:
Code:
#define AAA 2

int foo(void)
{
   int x;
  
   x = 0;

   return(x);
}

So, this rule is not redundant.
#3
We agree with LV's answer.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 2 Guest(s)