Don_A_Corbitt@cup.portal.com (07/27/90)
> 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 * ); > main() > { > Tlist *Head, *Walker; > AddLNode(&Head,Walker); /* This statement generates a warning */ > } > {apple|pyramid|sun}!octopus!stever} Disclaimer: I speak only for me! 8-) > Flames, grammar errors, spelling errrors >/dev/nul 1) The warnings you are getting are from the first parameter. When I cast it to AddLNode((void **)&Head, Walker); I don't get any warnings. Chris Torek gave you the correct answer. What made you think the warnings were from the second parameter? 2) Cross posting to alt.msdos.programmer, comp.lang.c, comp.os.msdos.programmer usually means too many people are going to see the question and answer. I'm leaving the groups, but I suggest followups (if any) by mail. --- Don_A_Corbitt@cup.portal.com Not a spokesperson for CrystalGraphics, Inc. Mail flames, post apologies. Support short .signatures, three lines max.
karl@haddock.ima.isc.com (Karl Heuer) (07/27/90)
>> void AddLNode(void ** Hptr, void * Nptr); >> Tlist *Head, *Walker; >> AddLNode(&Head,Walker); /* This statement generates a warning */ > >The warnings you are getting are from the first parameter. When I cast >it to AddLNode((void **)&Head, Walker); I don't get any warnings. It should be noted that, although it silences the warnings, the cast makes the code incorrect. It will fail on (existing) implementations where `Tlist *' and `void *' do not have the same internal format. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint Followups to comp.lang.c only.
karl@haddock.ima.isc.com (Karl Heuer) (07/27/90)
>> void AddLNode(void ** Hptr, void * Nptr); >> Tlist *Head, *Walker; >> AddLNode(&Head,Walker); /* This statement generates a warning */ > >The warnings you are getting are from the first parameter. When I cast >it to AddLNode((void **)&Head, Walker); I don't get any warnings. It should be noted that, although you can silence the warnings, the code is incorrect with or without the cast. It works on vaxlike architectures, but will probably fail on (existing, not hypothetical) implementations where `Tlist *' and `void *' do not have the same internal format. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint Followups to comp.lang.c only.