Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C versus C++
#3
I think the original question asked which version of MISRA to use for each project.
Obviously MISRA C++ should be used for C++ code. One can also suggest that MISRA C can be used for the C code, however I believe, in your case, that it won't be long before your C code becomes C++ code and thus one should apply both to the C code.
Ideally, I would suggest that you develop your own standards which include both sets of MISRA rules and also addresses the C/C++ incompatibility issues (these are all detailed in the C++ standard). For example...

Code:
int test( void )
{
    return 2 //* 2 */
    ;
}

... is both legal C and C++ code (although not MISRA compliant!) but will return different results in C90 and C++!

This way one can write C code that can be later ported to C++ without too much heart ache.
I have found that Programming Researches QA-C provides some excellent C/C++ compatibility checks that can also be used as part of your own standards. Other static analysis tools exist but I have limited experience with them.
In my view MISRA should be regarded as a minimum set of requirements for your code. You coding standards can address further issues specifically not covered in MISRA C.
I think Les Hattons 'Safer C' is an essential read for anyone involved in writing ANY software.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)