In plain C, an empty parameter list doesn't mean that the function has no parameters, but rather that the list of parameters may still be specified later. To correctly declare a function without any parameters, you specify the parameter list as void.
Note that this syntax is also allowed in C++ for backward compatibility, but meaningless because the default is an empty parameter list there (declaring the parameters later doesn't work with parameter-based function overloading).
View all comments
Show parent comment
2
u/visvis Feb 03 '22
In plain C, an empty parameter list doesn't mean that the function has no parameters, but rather that the list of parameters may still be specified later. To correctly declare a function without any parameters, you specify the parameter list as
void.Note that this syntax is also allowed in C++ for backward compatibility, but meaningless because the default is an empty parameter list there (declaring the parameters later doesn't work with parameter-based function overloading).