Login Register


A Question About C filter_list
Author
Message
RE: A Question About C #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.

Reply





Messages In This Thread
A Question About C - by CPU - 10-15-2015, 04:26 AM
RE: A Question About C - by pizzaguy541 - 10-16-2015, 10:40 AM
RE: A Question About C - by CPU - 10-17-2015, 12:44 AM
RE: A Question About C - by lord of the flies - 10-17-2015, 03:01 AM
RE: A Question About C - by CPU - 10-17-2015, 03:47 AM
RE: A Question About C - by 0xDEAD10CC - 10-17-2015, 05:49 AM
RE: A Question About C - by pizzaguy541 - 10-17-2015, 02:16 PM
RE: A Question About C - by CPU - 10-17-2015, 08:55 PM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 04:54 AM
RE: A Question About C - by CPU - 10-18-2015, 05:04 AM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 05:10 AM
RE: A Question About C - by CPU - 10-18-2015, 05:23 AM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 05:29 AM



Users browsing this thread: 1 Guest(s)