MISRA C++:2008 Rule 7-3-2
The identifier main shall not be used for a function other than the global function main
Description
Rule Definition
The identifier main shall not be used for a function other than the global function main.1
Rationale
Typically, the main
function lives in the global namespace and acts as the entry point to a program. The use of main
in other contexts might defy developer expectations.
Polyspace Implementation
The rule checker reports a violation if you use the identifier main
in a namespace other than the global namespace.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declarations |
Category: Required |
Version History
Introduced in R2013b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.