this post was submitted on 11 Feb 2025
350 points (95.6% liked)
Programmer Humor
32710 readers
407 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
besides not requiring a return value, what difference does it make?
@stebo02 @Bogus5553 Neither of them require a return value, but
void main
isn't legal C++.yeah I thought so, does it work in C?
void main(){...}
is not in the standard, but works on both MSVC and GCC (with warnings). I think it works on both C/C++, but you really shouldn’t use it in production. Just useint main(void){...}
, without any return value, which is permitted in the standard, and will return success iirc.It will also give an error if you try to add a return value anyways.