AT&T C compilers
Andrew Koenig
ark at alice.UUCP
Sun Feb 26 23:13:08 AEST 1989
In article <1071 at auspex.UUCP>, guy at auspex.UUCP (Guy Harris) writes:
[discussion about extern int bob(double (*)()); ]
> (Deep breath, count to 5) Prototypes are a relatively new feature in C
> implementations. Some compilers do not support them. The "Portable C
> Compiler", upon which many (most?) UNIX C compilers - including the ones
> AT&T supplies - are based, does not support them.
> The declaration in question appears to be correct, except that it says
> the argument taken by "bob" is a pointer to a function returning
> "double", but doesn't say what sort of arguments that function takes. I
> think this is legal, however.
Sure it is -- the arguments of the function are unspecified so it's
up to the programmer to get them right when calling it.
> I don't know whether it's legal C++ or not; if it is, I suspect the
> declaration says, in C++, that the function to which the pointer points
> takes no arguments (since C++, unlike C, does not have the notion of
> "old-style" function declarations where an empty argument list indicates
> that the types of the arguments are unknown).
Exactly right.
It is legal C++, by the way, but presently available C++ translator
do not support it -- it is hard to parse.
You can achieve the same effect by a semantic hack:
typedef (*doublefp)();
extern double bob(doublefp);
or by a syntactic hack:
extern double bob(auto double(*)());
The (not yet generally available) C++ translator on my machine supports
the original form of the declaration just fine, so I imagine it will
also be supported by the next version released.
--
--Andrew Koenig
ark at europa.att.com
More information about the Comp.lang.c
mailing list