Posted Oct 14, 2011 1:55 UTC (Fri) by galanom (guest, #80787)
[Link]
It is illegal in C11 however.
Dennis Ritchie RIP your legacy...
Posted Oct 14, 2011 3:28 UTC (Fri) by HelloWorld (guest, #56129)
[Link]
> It is illegal in C11 however.
No it's not, at least not in the current draft. Section 6.7.6.3, paragraph 14:
"An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters."
Dennis Ritchie RIP your legacy...
Posted Oct 14, 2011 21:45 UTC (Fri) by jengelh (subscriber, #33263)
[Link]
IIRC, the standard demanded that main be one of two signatures: int main(void) or int main(int, char **) only. That would be in line with page 24's "you should use int main(void) - because the standard says so", provided the PDF is right.
Dennis Ritchie RIP your legacy...
Posted Oct 17, 2011 11:50 UTC (Mon) by jwakely (subscriber, #60262)
[Link]
An empty
list in a function declarator that is part of a definition of that function specifies that the
function has no parameters.
i.e. In a function definition (as opposed to a prototype) int main() is the same as int main(void) and so is correct.
Dennis Ritchie RIP your legacy...
Posted Oct 14, 2011 16:32 UTC (Fri) by tjc (subscriber, #137)
[Link]
On a more pragmatic level, gcc -Wall doesn't complain about main(). If it's good enough for -Wall, then it's good enough for me. ;)
Dennis Ritchie RIP your legacy...
Posted Oct 14, 2011 16:41 UTC (Fri) by HelloWorld (guest, #56129)
[Link]
I disagree. I think that -Wall should print many more warnings than it does.
Dennis Ritchie RIP your legacy...
Posted Oct 15, 2011 11:37 UTC (Sat) by da4089 (subscriber, #1195)
[Link]