Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!pacbell.com!tandem!zorch!vsi1!octopus!stever From: stever@Octopus.COM (Steve Resnick ) Newsgroups: comp.lang.c Subject: Re: Suspicious pointer conversion warning in Turbo C 2.0 Message-ID: <1990Jul28.150116.7513@Octopus.COM> Date: 28 Jul 90 15:01:16 GMT References: <1990Jul25.230836.2442@Octopus.COM> <3629@tuminfo1.lan.informatik.tu-muenchen.dbp.de> Reply-To: stever@octopus.UUCP (Steve Resnick ) Organization: Octopus Enterprises, Cupertino CA Lines: 45 In article <3629@tuminfo1.lan.informatik.tu-muenchen.dbp.de> rommel@lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) writes: >In article <1990Jul25.230836.2442@Octopus.COM> stever@octopus.COM (Steve Resnick ) writes: >> As far as I know, when I provide a prototype for a function which accepts >> a void pointer, the compiler should not bitch about type conversions between >> pointers. The code fragment below generates a warning message when I pass a >> pointer to a structure. The parameter bitched about is the second pointer. > >>void AddLNode(void ** Hptr, void * Nptr); >>void * DelLNode(void ** , void * ); > >> Tlist *Head, *Walker; >> AddLNode(&Head,Walker); /* This statement generates a warning */ >> DelLNode(&Head,Walker); /* This statement generates a > >As you said, you can pass any pointer to a function declared with a >pointer to void as an argument. But you did not declare such a function. >"void *" and "void **" is not the same! The first is a pointer to void >but the second is a pointer to a pointer variable. > >You should declare: >>void AddLNode(void * Hptr, void * Nptr); >>void * DelLNode(void * , void * ); > >Although you probably mean something what is called "call by reference" >you shoud declare it this way to avoid the warning. This declaration >does not prevent you to do the same in the AddLNode, DelLNode functions. >You will have to cast the arguments in these function to what you want >anyway. > Let me note here that the first parameter is accepted without note by the compiler. If I call AddLNode as AddLNode(&Head,(void *)Tlist); my compiler warnings go away, also, the Turbo C IDE points to the second parm as the source of my error. It seems to accept the first one fine. Cheers! Steve -- ---------------------------------------------------------------------------- {apple|pyramid|sun}!octopus!stever} Disclaimer: I speak only for me! 8-) Flames, grammar errors, spelling errrors >/dev/nul ----------------------------------------------------------------------------