3 ms·
Not exactly. As of C17, the function definition you wrote implies that the function has no arguments, just like in C++. However, a declaration that is not part
by el_pollo_diablo 3y ago
Not exactly. As of C17, the function definition you wrote implies that the function has no arguments, just like in C++. However, a declaration that is not part of a definition, like
void fun();
(which you typically find in a header file) indeed does not say anything about the function's arguments. You have to write
void fun(void);
to specify that the function takes no arguments. For consistency, you can (and probably should) also use that style in the function's definition, but you don't have to.
Anyway, C23 will align C's behavior with C++: void fun() will mean the same thing as void fun(void), whether as part of a function definition or not.
- kazinator 3y agoI have N3096.pdf (April Fool's 2023 draft) perpetually open; will check it.