Main function signature equivalency
- Dominant language
- C#
- Stars
- 451
- Forks
- 49
- Avg merge
- 13h 59m
- Merged PRs (30d)
- 6
Description
C17 standard's section **5.1.2.2.1 Program startup** tells us that
> The function called at program startup is named `main`. The implementation declares no prototype
for this function. It shall be defined with a return type of int and with no parameters […] or with two parameters […]: `int main(int argc, char *argv[]) { /* ... */ }` or equivalent; or in some other implementation-defined manner.
The troubling clause here is "or equivalent". What is considered as an equivalent exactly?
I suppose that:
- declaring more or less arguments isn't "equivalent"
- converting between `char*[]` and `char**` and `char[]*` or whatever _is_ equivalent
- converting of non-const arguments to const ones is equivalent
- declaring `main` as a function with empty parameter list is equivalent
- declaring `main` as `int main(...)` is not equivalent
So, say, `int main(int, char*[])` and `int main(const int, const char * const *)` are allowed, while `int main(int, char*)` or `int main(int, int*)` aren't.
As of now, we only support `char*[]` and not `char**` for the `argv` parameter, which should be fixed.
Contributor guide
Assessment
This issue has not been assessed yet.