Suspicious pointer conversion warning in Turbo C 2.0

Kai-Uwe Rommel rommel at lan.informatik.tu-muenchen.dbp.de
Fri Jul 27 21:09:52 AEST 1990


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.

Kai Uwe Rommel

--
/* Kai Uwe Rommel
 * Munich
 * rommel at lan.informatik.tu-muenchen.dbp.de
 */



More information about the Comp.lang.c mailing list