"void **" : Is it valid and what does it mean?
Georg Wittig
wittig at gmdzi.gmd.de
Wed May 29 18:37:30 AEST 1991
hp at vmars.tuwien.ac.at (Peter Holzer) writes:
>[...good explanation why void ** isn't a pointer to any pointer
>>Why do you want to do _that_?
>For some reason, which is not relevant here, msg is not a pointer to
>the structure, but a pointer to a pointer to structure. Of course one
>common error is to define a struct foo * mymsg and then pass mymsg
>instead of &mymsg. With the current prototype this error is not
>detected by the compiler, but if some type `pointer to any pointer'
>existed, this type of error could be catched. Unfortunately this is not
>possible in C.
Why not use unions? Example:
typedef union { struct struct1 *p_struct1;
struct struct2 *p_struct2;
...
} my_union_t;
and pass the union address to your function:
myfunc (&myunion);
...
myfunc (my_union_t *p_union){
...
p_union -> p_struct2 -> ...
This has the advantage that you MUST define which structures are allowed in
that context, and the compiler can check consistency. ... And you don't
need void **.
--
Georg Wittig GMD-Z1.IT P.O.Box 1240 | "Freedom's just another word
D-W-5205 St. Augustin 1 (Germany) | for nothing left to lose"
email: wittig at gmdzi.gmd.de | (from "Me and Bobby McGee",
telephone: (+49) 2241 14-2294 | Janis Joplin, Kris Kristofferson)
More information about the Comp.lang.c
mailing list