8

Rule 2.2 in MISRA states that "source code shall only use /* ... */ style comments". Does any one know what is the rationale for this rule? what is wrong with // style comments?

duffymo
  • 305,152
  • 44
  • 369
  • 561
Kamyar Souri
  • 1,871
  • 19
  • 29
  • My guess is that it's an old C-style standard that hasn't been updated since the 90s. – duffymo Mar 02 '12 at 18:38
  • 1
    @duffymo No it is a very modern C coding standard for critical systems. They haven't added support for C99 yet, because of various hazards and UB in C99, but they will add support to it in the next version of the standard. See my answer below. – Lundin Mar 12 '12 at 21:08
  • Thank you for the instruction. – duffymo Mar 12 '12 at 22:37
  • If you are using Lint for checking misra rules, disable such errors – AlphaGoku Dec 14 '17 at 06:50

2 Answers2

10

MISRA 1998 and 2004 only support the C90 standard ("ANSI C"). In that standard, // comments are not allowed and code containing them will not compile on C90 compilers.

MISRA 2012 supports the C99 standard and // comments.

Lundin
  • 195,001
  • 40
  • 254
  • 396
4

Further to Lundin's reply, MISRA-C:2012 (which covers C99) DOES allow // style comments

Andrew
  • 2,046
  • 1
  • 24
  • 37