In C89 you do not have to declare a function before calling it; however if you do call an undeclared function, it is as if you declared the function as:
int funcname();
The empty parentheses do not mean that the function takes no parameters; it just means that our declaration is not a prototype. The number and types of the parameters are unknown at this stage (but it isn't a function taking a variable argument list like printf()
because even in C89, those must have a prototype in scope when they are used).
If the actual function returns something other than int
, or you call it with the wrong type or number of parameters, or if any of the parameters have a different type after the default argument promotions are applied, then calling the function causes undefined behaviour.
Your code doesn't fall foul of any of those limitations, so your code is correct in C89. However it's considered good style to use function prototypes anyway as it enables the compiler to detect all of those conditions and report an error.
In C99 you do have to declare the function before calling it. An appropriate prototype would be:
int Initialize(struct can *elC);
Also I would advise to use C99 or C11 if your compiler supports them. Regarding the use of []
in a function parameter list, see here.