Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!decvax!ucbvax!sdcsvax!sdchem!tps From: tps@sdchem.UUCP (Tom Stockfisch) Newsgroups: net.lang.c Subject: uses of void Message-ID: <277@sdchema.sdchem.UUCP> Date: Sun, 10-Aug-86 21:22:12 EDT Article-I.D.: sdchema.277 Posted: Sun Aug 10 21:22:12 1986 Date-Received: Mon, 11-Aug-86 07:55:43 EDT Reply-To: tps@sdchema.UUCP (Tom Stockfisch) Distribution: na Organization: Chemistry Dept, UC San Diego Lines: 36 I want to be able to use "void *" in a generic sorting function and I tried something like sort( (void *)&foo[0], (void *)&foo[20], sizeof(foo), compare_foos ); . . . void sort( beg, end, size, compare ) void *beg, *end; int size; int (*compare)(); { int nelements = (end - beg) / size; for ( p = beg; p < end; p += size ) ...; ... } My compiler (4.2BSD running on a Celerity) when into an infinite loop trying to parse (end - beg) I (naively?) thought that pointer arithmetic would work with "void *", and that it would work in the same abstract units as "sizeof()", so that all previous generic "char *" kludges could be replaced by "void *". What are the (proposed and current) legal operations for "void *" besides assignment, casting, and passing as a parameter? -- Tom Stockfisch, UCSD Chemistry -- -- Tom Stockfisch, UCSD Chemistry