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

be consistent about our defintion of main #341

Merged
merged 2 commits into from
Mar 29, 2017
Merged

be consistent about our defintion of main #341

merged 2 commits into from
Mar 29, 2017

Conversation

ppannuto
Copy link
Member

Closes #338.

This mostly implements the discussion from the issue thread, it:

  • marks our _start in crt1 as weak
  • overrides _start in tests where access memory regions is nice
    • I view this as somewhat niche and a non-binding interface for now
  • defines that standard main prototype as int main(void)

In the original issue thread, we'd suggested a prototype of void main(void),
as Tock currently ignores the return value of processes. Unfortuntely, -Wall
turns on -Wmain by default, which results in

main.c:6:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main(void) {
      ^~~~

while we could explicitly turn this off (-Wno-main), my current feeling is
that writing int main is pretty stock for C, and having a return value from a
process may be useful someday (i.e. returning 0 means this process meant to
exit). Sure, most things probably won't ever return, but I don't think it hurts
to stick with C convention here and let things return a value.

Closes #338.

This mostly implements the discussion from the issue thread, it:

  - marks our `_start` in crt1 as weak
  - overrides `_start` in tests where access memory regions is nice
     - I view this as somewhat niche and a non-binding interface for now
  - defines that standard main prototype as `int main(void)`

In the original issue thread, we'd suggested a prototype of `void main(void)`,
as Tock currently ignores the return value of processes. Unfortuntely, `-Wall`
turns on `-Wmain` by default, which results in

    main.c:6:6: warning: return type of 'main' is not 'int' [-Wmain]
     void main(void) {
          ^~~~

while we could explicitly turn this off (`-Wno-main`), my current feeling is
that writing `int main` is pretty stock for C, and having a return value from a
process may be useful someday (i.e. returning 0 means this process meant to
exit). Sure, most things probably won't ever return, but I don't think it hurts
to stick with C convention here and let things return a value.
@alevy
Copy link
Member

alevy commented Mar 29, 2017

Something to the effect of "returning from main with a value other than 0 is currently undefined"?

@alevy is this roughly what you wanted?
@alevy
Copy link
Member

alevy commented Mar 29, 2017

@ppannuto merge/squash at will

@ppannuto ppannuto merged commit 7790424 into master Mar 29, 2017
@ppannuto ppannuto deleted the main-type-sig branch March 29, 2017 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants