Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-787

Source code should only use /* ... */ style comments

    Details

    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Legacy Key:
      C99CommentUsage
    • Targeted languages:
      Java
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • MISRA C 2004:
      2.2

      Description

      This excludes the use of // C99 style comments and C++ style comments, since these are not permitted in C90. Many compilers support the // style of comments as an extension to C90. The use of // in preprocessor directives (e.g. #define) can vary. Also the mixing of /* ... */ and // is not consistent. This is more than a style issue, since different (pre C99) compilers may behave differently.

      Noncompliant Code Example

      int main(int argc, char* argv[])
      {
        // Do nothing - Noncompliant
        return 0;
      }
      

      Compliant Solution

      int main(int argc, char* argv[])
      {
        /* Do nothing - Compliant */
        return 0;
      }
      

      See

      • MISRA C:2004, 2.2 - Source code shall only use /* ... */ style comments.

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4366 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: