Function-types: compatability, and typedefs
Richard O'Keefe
ok at cs.mu.oz.au
Tue Sep 5 13:41:50 AEST 1989
I wrote
int cmp(char **s1, char **s2) { return strcmp(*s1, *s2); }
flaps at dgp.toronto.edu (Alan J Rosenthal) correct this to
int cmp(void *s1, void *s2) { return(strcmp(*(char **)s1, *(char **)s2)); }
Karl Heuer pointed out
This isn't just a quibble. There are many real machines out there that have
more than one pointer format. The code will fail in mysterious ways if you
don't declare the formal arguments to be the same type as the actuals.
Related but different question:
I believe that the draft standard requires void* and char* to have the
same representation. I understand that this doesn't mean that char*
and char** will be the same, or that void* and char** will be the same,
but will void** and char** be the same?
More information about the Comp.lang.c
mailing list