pointer to incomplete type?

Alan J Rosenthal flaps at dgp.toronto.edu
Wed Jun 6 07:27:27 AEST 1990


jejones at mcrware.UUCP (James Jones) writes:
>On computers for which pointers to different types don't have the same format,
>how can one safely declare a pointer to an incomplete structure, union, or
>enumerated type?

I think "struct generic *" will work for structures on all compilers I've heard
of.  Strictly speaking, it's not legal, but I haven't heard of different kinds
of structure pointers having different formats.  Same for unions.

For enumerated types, I don't think you can do it, although, again, they
allocate int space on all compilers I've heard of.

Anyway, except in the case of adding kludges to poorly written code, this
should not be necessary.  Just #include the correct header file, or if the
type definition appears in a .c file, move it into a .h file and #include
it in both .c files.

ajr



More information about the Comp.std.c mailing list