MISRAC++2008-7-3-2
In this section:
Synopsis
(Required) The identifier main shall not be used for a function other than the global function main.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Only the global main function shall be named "main". This check is identical to MISRAC++2023-6.0.4.
Coding standards
- MISRA C++ 2023 6.0.4
(Required) The identifier main shall not be used for a function other than the global function main
Code examples
The following code example fails the check and will give a warning:
namespace {
// Test if word 'main' is in a string.
bool main(const char* s) {
// ...
}
}
int main() {
return 0;
}
The following code example passes the check and will not give a warning about this issue:
namespace {
// Test if word 'main' is in a string.
bool has_main(const char* s) {
// ...
}
}
int main() {
return 0;
}