Consider a C++ function that I want to interface it in C (e.g., int foo()
) that takes no input arguments.
The lack of input arguments in C can be expressed as int foo(void);
, while int foo()
in C means arbitrary number of input arguments.
However, in C++ int foo()
means a function that takes no arguments and int foo(void)
is considered a C backward compatibility remnant that should be avoided.
Considering the above, what's the most proper?
Option 1:
C header declaration :
int foo(void);
C++ file definition :
int foo(void) { ... }
Option 2:
C header declaration :
int foo();
C++ file definition :
int foo() { ... }
Option 3:
C header declaration :
int foo(void);
C++ file definition :
int foo() { ... }