How do I declare...
Scott Pace
scott at othervax.UUCP
Wed Aug 28 04:39:58 AEST 1985
>> Either I'm missing the perfectly obvious or I've found something
>> that's impossible to declare in C, even though it makes sense.
>You have discovered a fundamental flaw in C type notation. In essence,
>C allows recursive types only in structs, unions, and enums (and I'm not
>sure how it would be usefull in enums, so that one can be ruled out for
>practical purposes).
>
>Thus, if you want an array of pointers to arrays of pointers, you can't
>do it. Nor can you declare functions returning pointers to functions.
Well, our compiler seems to handle these sort of constructs ok:-
looking at an array of pointers to arrays of pointers first...
int *(*foo1[10])[];
here foo1 is an array of pointers, each pointer pointing to an array
of pointers to int's.
Thus an integer element might be accessed as follows:
*(*foo1[1])[2] and another way might be **foo1[0]
now looking at functions returning pointers to functions:-
int *(*func1())();
here func is a function returning a pointer to a function, and this
function returns a pointer to an int.
Thus you could do things like:
int *(*func2)(); /*pointer to a function returning a pointer to int*/
int *x;
.
.
.
func2 = func1();
x = (func2)();
.
.
etc.
Cheers
Scott Pace, ...!philabs!micomvax!othervax!scott
(I hope I got all that right!!!)
More information about the Comp.lang.c
mailing list