Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Macros & 14.3 II
#1
Since, according to http://www.misra-c2.com/forum/viewtopic.php?t=264, the following code is not permitted:
Code:
#if debugging
#define ASSERT(x)    asserttest(x)
#else
#define ASSERT(x)
#endif

void f(int *p)
    {
    ASSERT(p != 0);
    }

How would one make code well formed with respect to assertion macros?
#2
Moving the semicolon to the macro definition removes the null statement issue.
Code:
#if debugging
#define ASSERT(x)    asserttest(x); /* not compliant with 19.4. */
#else
#define ASSERT(x)
#endif

void f(int *p)
{
    ASSERT(p != 0)
}
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 2 Guest(s)