Rule 3.1 - Hyperlinks in comments?

Moderators: misra-c, david ward

Post Reply
Andrew Banks
Posts: 38
Joined: Fri Feb 15, 2008 10:45 am
Company: LDRA & Intuitive Consulting
Location: Farnborough, Hampshire
Contact:

Rule 3.1 - Hyperlinks in comments?

Post by Andrew Banks » Fri Sep 02, 2016 12:00 pm

Cross-post from the MISRA C/C++ LinkedIn group
Is there any chance MISRA could alter Rule 3.1 to allow common hyperlinks in C comments such that a Deviation isn't required:

Code: Select all

/*
* See https://somewhere.over.the.rainbow/way/up/high.htm
*/
I use direct references to RFCs in source files that allow clicking in Visual Studio to open up a browser at the relevant spec. MISRA sees this as evil. If https: or http: occurs before //, then there isn't much confusion about commenting...
The (perfectly sound) Rationale for the Rule is to detect missing */ comment terminators.

There is already an Exception to permit // within a */ comment... so a further Exception to permit hyperlinks of the form http://, https://, ftp:// or ftps:// (without requiring a Deviation) seems reasonable?
-----
Andrew Banks
Chairman, MISRA C WG
Posting in a personal capacity

misra-c
Posts: 569
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 3.1 - Hyperlinks in comments?

Post by misra-c » Fri Sep 23, 2016 8:46 am

C90 and C99 strictly conforming compilers have well-defined behaviour for // within a /* comment. However many compilers are non strictly conforming and a variety of behaviour has been observed.

We suggest two methods for including hyperlinks within a comment.
  1. In C99, the use of // within a // comment is permitted in the Exception to this rule.

    Code: Select all

    // See  https://somewhere.over.the.rainbow/way/up/high.htm
  2. Create a deviation/permit which permits the inclusion of // within a /* comment after checks have performed on the compiler that is used to confirm that such inclusion behaves as expected.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.3 Comments”