From §6.2.7.5 (page 66):
EXAMPLE Given the following two file scope declarations:
int f(int (*)(), double (*)[3]); int f(int (*)(char *), double (*)[]);
The resulting composite type for the function is:
int f(int (*)(char *), double (*)[3]);
Above the example, they explain that a composite type is a type, compatible with two different types. I would intuitively understand the phrase "composite type" as meaning "structures and unions", which appears to be way off-target.
What is a composite type in C and what is it used for? Could someone please explain the example above in details?
In the C language definition, arrays and structs are aggregate types (types composed of multiple elements). Unions are kind of their own animal, since they can only take on the value of one element at a time.
Composite types are more of an issue for compiler implementors, rather than us run-of-the-mill code monkeys. You and I would not attempt to define a composite type, or declare objects of that type.
In the example given, you have two file scope declarations for a function
f
that are slightly different from each other. Based on the rules presented in 6.2.7/3, the compiler determines a type that works for both, such that it can enforce type semantics at compile time (i.e., any calls tof
can be properly checked, even with the slightly different declarations) and generate the proper machine code to call the function.I'm probably not the right person to answer this, but for what it is worth, here is the C99 rationale, which may be helpful: