3 ms·
A quick question: the book (at least early on) advocates this for main: # implied int; implied void main() { # whatever exit(0) # or EX
by telemachos 16y ago
A quick question: the book (at least early on) advocates this for main:
# implied int; implied void
main() {
# whatever
exit(0) # or EXIT_SUCCESS
}
Is this simply a stylistic choice (rather than a more explicit int main(void) and return(0)). I'm mostly curious, but I know that how to deal with main can be a sacred cow.
Edit: And sure enough clang (by default) and gcc (with -Wall) both issue warnings.
- johnswamps 16y agoThe book was written 20 years ago, before the C99 spec was released. main() was acceptable but discouraged in C89, which is why -Wall (or more precisely -Wimplicit-int) displays a warning. It's disallowed by the C99 spec and will always give you a warning.
- deleted 16y ago[deleted]