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

The name "main" should not be used for any function other than the global "main" function

    Details

    • Default Severity:
      Blocker
    • Impact:
      High
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      GlobalMainFunction
    • Covered Languages:
      C++
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min
    • MISRA C++ 2008:
      7-3-2
    • PC-Lint:
      9142

      Description

      A global function named main is the entry point to the program, and is the only identifier which must be in the global namespace. The use of main for other functions may not meet developer expectations.

      Noncompliant Code Example

      int main() {       // Compliant
      }
      
      namespace {
        int main() {     // Noncompliant
        }
      }
      namespace NS {
        int main() {     // Noncompliant
        }
      }
      

      See

      • MISRA C++:2008, 7-3-2 - The identifier main shall not be used for a function other than global function main.

        Attachments

          Issue Links

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

            Activity

              People

              • Assignee:
                evgeny.mandrikov Evgeny Mandrikov
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: