371
unsafeCode (lemmy.ml)
submitted 2 months ago by PandaDEV@lemmy.ml to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] stebo02@lemmy.dbzer0.com 9 points 2 months ago

besides not requiring a return value, what difference does it make?

[-] barubary@infosec.exchange 9 points 2 months ago

@stebo02 @Bogus5553 Neither of them require a return value, but void main isn't legal C++.

[-] stebo02@lemmy.dbzer0.com 2 points 2 months ago

yeah I thought so, does it work in C?

[-] Bogus5553@lemm.ee 4 points 2 months ago* (last edited 2 months ago)

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 use int main(void){...} , without any return value, which is permitted in the standard, and will return success iirc.

[-] Buddahriffic@lemmy.world 2 points 2 months ago

It will also give an error if you try to add a return value anyways.

this post was submitted on 11 Feb 2025
371 points (95.1% liked)

Programmer Humor

35305 readers
283 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS