RE: A Question About C 10-18-2015, 05:04 AM
#10
(10-18-2015, 04:54 AM)0xDEAD10CC Wrote: It's not opinion based. The standard does not require that a compiler implicitly add a proper return type for you, even though some compilers will do it regardless of what the standard says, but then you are relying on implementation specific behavior to define what really happens which is horrible. You should never be relying on anything that is non-standard. There's nothing opinion based about properness. In C99 the mention about not having a return type specifier is removed, which would make this undefined behavior... Of which, could have easily been avoided if you did the appropriate thing and explicitly write 'int' before the main() function signature. This way you aren't relying on an old C89 dialect to be consistent with all newer standards of the language.
ALWAYS explicitly specify the return type.
False, you can, but a return type of void means that anything which calls the function won't care what was placed into the eax register. This doesn't mean you can't populate the data which that register holds yourself, nor does it mean that you can't obtain the value after a function call.
My C compiler makes a function's return type default to "int", and I'll always be using that compiler, but you do somewhat have a point.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)