I’m working with some C code that does not contain function prototypes for a certain class of functions. Are there any advantages to not using function prototypes? The functions never call each other and have no parameters. The code changes a lot, so maybe it’s just one less line to edit?
Share
Function prototypes are for external functions. My rule is that every non-static function gets a prototype, except main(). I use the ‘-Wmissing-prototypes’ GCC option. Usually what it catches is when I forget to declare a function static.
Also, declare functions in C this way:
And not this way:
Because the second way means that the function takes an unspecified number of parameters, which isn’t what you want (it’s for compatibility with pre-ANSI C).