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

Preprocessor operators "#" and "##" should not be used

    Details

    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Legacy Key:
      PPStringifyAndPastingUsage
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      30min
    • MISRA C 2004:
      19.13
    • MISRA C 2012:
      20.10
    • MISRA C++ 2008:
      16-3-2
    • PC-Lint:
      484, 1484

      Description

      The evaluation order of both the # and ## preprocessor operators is unspecified. Compilers have been known to implement these operators inconsistently, therefore, to avoid these problems, do not use them.

      Noncompliant Code Example

      #define A(Y)   #Y    /* Noncompliant */
      #define A(X,Y) X##Y  /* Noncompliant */
      

      See

      • MISRA C:2004, 19.13 - The # and ## preprocessor operators should not be used.
      • MISRA C++:2008, 16-3-2 - The # and ## operators should not be used.
      • MISRA C:2012, 20.10 - The # and ## preprocessor operators should not be used

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4370 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: