From: Message-Id: <200302081532.h18FW3u24717@speedy.ludd.luth.se> Subject: GCC warning - incompatible pointer type To: djgpp AT delorie DOT com Date: Sat, 8 Feb 2003 16:32:03 +0100 (CET) X-Mailer: ELM [version 2.4ME+ PL78 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-Information: Please contact the ISP for more information X-MailScanner-SpamScore: ss Reply-To: djgpp AT delorie DOT com In article <1391a.6717$kz5 DOT 662443 AT news1 DOT east DOT cox DOT net> Jason Kircher wrote: : Given buf is an array of 20 3-character strings that needs to be sorted, : I used the following: : char buf[20][4]; To me it looks like buf is an array of 4 19-character strings. : ... : qsort (buf, 20, 4, strcmp); 1 2 3 4 : gcc -Wall -o foo foo.c : gcc gives me the warning: : warning: passing arg 4 of `qsort' from incompatible pointer type qsort expects a function taking two "const void *" arguments (and returning an "int"). strcmp is a function taking two "const char *" arguments. Evidently the C idea of every pointer is compatible to "void *" doesn't extend to "void *"s in functions. : The program works fine, however, it's just that the warning spooks me. : Other than not saying -Wall, any idea how to get rid of this warning? Why don't you "info libc a qsort" and see how the example solves this? Alternatively is should be a safe to use strcmp directly (but don't hold me to this in court), so a functioncast (if possible) would make the compiler quiet. Right, MartinS