"John Matthews" <jm5...@...> wrote:
> In C99, if you have the following function prototypes:
>
> void funcX();
This is _not_ a prototype in C99 (or C90.)
> void funcY(void);
>
> funcX declares a function with no parameter specification,
No, it declares a function with an unspecified number of
parameters. [Though the function cannot be variadic.]
> and funcY declares a function with no parameters. Hence
> the funcX prototype could be considered 'wrong', or at
> least undesirable, because it is incomplete.
It's wrong as a prototype because it isn't a prototype.
> (If your code calls funcX(), PC/Flexe-lint will complain
> that there is no prototype.)
Hooray! :-)
> However, what if you miss out the void in the function
> definition?
> That is, what is the difference (if any) between
>
> int main() { /* do stuff */ return 0; }
>
> and
>
> int main(void) { /* do stuff */ return 0; }
>
> ?
The same difference as any other non-prototyped functions:
calls with the incorrect number of arguments will not
require a diagnostic.
P.S. IIRC, C++ has deprecated this use void to indicate a
function with no parameters.
--
Peter