This question is a branch of `f (void)`, which means the absence of parameters in C ++ 11 or C?
Several people answered this question and indicated that in C the value of a function prototype
void func ()
lies in the fact that func is a function that returns nothing (void) and whose parameters are currently unknown.
They further suggested that you could make this declaration, and then call the function with some arguments, such as:
func (1, 2, 3);
So, I did it, I did a test to make sure that it works, and I'm not surprised that he does it.
Here is the func.c that contains main()
#include <stdio.h> extern void func (); int main (int ac, char ** av) { func (1, 2, 3); return 0; }
And here is func1.c, which contains the func() function
And here is my question (s)
Question 1:
When I run this program, I get, as expected, the output 1, 2, 3. This is a safe way to write code; that is, can we assume that ABI reliably guarantees that calling func() in main() will put three parameters in the right places (registers, stack, whatever) for func() to find them?
Question 2:
If the answer to 1 above is that it is safe, then your answer changes if func() implemented in some language other than C?