wij <wyniijj5@gmail.com> writes:
[...]
typedef int (*ptr)(); // ptr is pointer to int function
int H(ptr x, ptr y);
int D(ptr x)
{
int Halt_Status = H(x, x);
if (Halt_Status)
HERE: goto HERE;
return Halt_Status;
}
int main()
{
H(D,D);
return 0;
}
The code above does not compile:
Yes, it does (as you acknowledge in a later post).
This:
typedef int (*ptr)();
defines "ptr" as an alias for a type that can be described in English
as "pointer to function returning int". The empty parentheses
indicate that the function takes an unspecified but fixed number
and type(s) of arguments; this is an old-style declaration. [...]
The function H is declared but not defined. [...]
I'll note that the code (declares and) defines the function D,
but never calls it. The address of D is passed to H, but without
a definition of H we can't guess what it does with that address.
It's possible to rewrite the code to (a) avoid the use of old-style
function declarations [...]
The code as presented is a valid C *translation unit*, but it
is not a valid *program*,
and it has no behavior.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (3 / 13) |
Uptime: | 06:40:48 |
Calls: | 10,388 |
Calls today: | 3 |
Files: | 14,061 |
Messages: | 6,416,816 |
Posted today: | 1 |