Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main function signature equivalency #66

Open
Tracked by #65
ForNeVeR opened this issue Jan 16, 2022 · 0 comments
Open
Tracked by #65

Main function signature equivalency #66

ForNeVeR opened this issue Jan 16, 2022 · 0 comments
Labels
area:compiler Related to code compilation or type checking kind:feature New feature or request status:help-wanted Open for contributors

Comments

@ForNeVeR
Copy link
Owner

ForNeVeR commented Jan 16, 2022

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.

@ForNeVeR ForNeVeR changed the title Main function signature compatibility Main function signature equivalency Jan 16, 2022
@ForNeVeR ForNeVeR added kind:feature New feature or request status:help-wanted Open for contributors area:compiler Related to code compilation or type checking labels Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:compiler Related to code compilation or type checking kind:feature New feature or request status:help-wanted Open for contributors
Projects
None yet
Development

No branches or pull requests

1 participant