Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!uakari.primate.wisc.edu!aplcen!uunet!ingr!b11!polfer From: polfer@b11.ingr.com (? Polfer) Newsgroups: comp.lang.c Subject: void * compatibility Keywords: C void types Message-ID: <8770@b11.ingr.com> Date: 19 Sep 90 18:41:07 GMT Distribution: usa Organization: Intergraph Corp. Huntsville, AL Lines: 31 While porting some code to an ANSI compiler (NOT porting to ANSI), I received an error with code similar to the following: int (**command)(); ... *command = NULL; The warning was: "Type `void *' is not assignment compatible with type `int (*)()'." The compiler is not in full ANSI mode (we must keep using a non ANSI compiler on another platform), so prototyping is NOT being used. It turns out that Metaware High C defines NULL in stdio.h as "(void *)0". This gives a little bit more error checking than just using "0". My question is why the above code errors out. "*command" is a pointer to a function which returns int, but it is still a pointer. I understand that ANSI does not guarantee that pointers to different types will have the same internal repesentations, but isn't a "void *" supposed to be assignment compatible with ALL pointers? The fix is to use "*command = (int (*)())0;" or just plain "*command = 0;", neither of which yield errors. Could this be because "0" is considered the generic NULL pointer value while the explicit cast (void *) fouls the assignment? Any ideas would be appreciated! ----- Dan Polfer uunet!ingr!b11!dap!dan (UUCP) b11!dap!dan@ingr.com (Internet)