Talk:c/language/function declaration
The current text has: "The return type of the function, determined by the type specifier in specifiers-and-qualifiers and possibly modified by the declarator as usual in declarations, must be a complete non-array object type or the type void."
I can't find any requirement in the standard that the return type has to be complete in a function declaration. Is this an error?
Declarations such as struct opaque foo(void); are accepted just fine by compilers. Of course you cannot call the function unless the type is completed, nor can you define it, but for instance you can still create pointers to it and pass them around. Example on godbolt.
See also this StackOverflow question.
--Nate Eldredge (talk) 22:32, 11 December 2020 (PST)
[edit] possible mistake about scope
In this code sample:
int main(void) { int f(int); // external linkage, file scope f(1); // definition needs to be available somewhere in the program }
should'nt it be block scope ?