Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!wuarchive!uunet!mcsun!unido!gmdzi!wittig From: wittig@gmdzi.gmd.de (Georg Wittig) Newsgroups: comp.lang.c Subject: Re: "void **" : Is it valid and what does it mean? Message-ID: <4803@gmdzi.gmd.de> Date: 29 May 91 08:37:30 GMT References: <6001@goanna.cs.rmit.oz.au> <1991May28.115914.19879@email.tuwien.ac.at> Distribution: comp Organization: GMD - The German National Research Center for Computer Science Lines: 37 hp@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@gmdzi.gmd.de | (from "Me and Bobby McGee", telephone: (+49) 2241 14-2294 | Janis Joplin, Kris Kristofferson)