On 05/16/2012 02:31 AM, Per Jessen wrote:
Try this for the comparison function in line 36:
/* This is the comparison function used for sorting and searching. */ int critter_cmp (const void *a, const void *b) { const struct critter *c1=a, *c2=b; return strcmp (c1->name, c2->name); }
Per, Andreas, That works great and compiles without warning. This should also be updated in the manual. It may even be worth leaving the original unchanged and adding a paragraph with heading of something like "Using (void *) to eliminate qsort warnings". Then a quick explanation of why passing the structs to critter_cmp as void instead of struct critter fixes the problem. The "see the warning, see the solution, fix it" exercise always helps cement how/why you do things in one particular way or another. (at least for slow learners like me :) -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org