This is a draft version of a MISRA C++ 202x rule proposed for public review.
MISRA Rule 6.0.4
Category: Required
Analysis Type: Decidable,Single Translation Unit
Amplification
This rule also applies to any other entry points defined by the implementation.
Rationale
main
(or its equivalent) 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.
Example
int main() // Compliant
{
}
namespace
{
int main() // Non-compliant
{
}
}
namespace NS
{
int main() // Non-compliant
{
}
}
Copyright The MISRA Consortium Limited © 2023