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

Pre-defined macros should not be defined, redefined or undefined

    Details

    • Message:
      Remove this XXX directive
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • MISRA C 2004:
      20.1
    • MISRA C 2012:
      21.1
    • MISRA C++ 2008:
      17-0-1
    • PC-Lint:
      136, 1136

      Description

      The standard, predefined macros, such as _FILE and LINE_, are primarily intended for use by the implementation, and changing them could result in undefined behavior.

      This rule checks that the following predefined macros are not defined, undefined, or redefined: assert, errno, _FILE, LINE, TIME, DATE, TIMESTAMP, COUNTER, INCLUDE_LEVEL, BASE_FILE_, and _Pragma.

      Noncompliant Code Example

      #undef __LINE__
      

      See

      • MISRA C:2004, 20.1 - Reserved identifiers, macros and functions in the standard library shall not be defined, redefined, or undefined
      • MISRA C++:2008, 17-0-1 - Reserved identifiers, macros and functions in the standard library shall not be defined, redefined, or undefined
      • MISRA C:2012, 21.1 - #define and #undef shall not be used on a reserved identifier or reserved macro name

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: