Suspicious pointer conversion warning in Turbo C 2.0

Steve Resnick stever at Octopus.COM
Sun Jul 29 01:01:16 AEST 1990


In article <3629 at tuminfo1.lan.informatik.tu-muenchen.dbp.de> rommel at lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) writes:
>In article <1990Jul25.230836.2442 at Octopus.COM> stever at 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
----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list