From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,6e2fef38c9bfb3bf X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,6e2fef38c9bfb3bf X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1995-02-03 10:59:49 PST Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!kcgl1.eng.ohio-state.edu!JONESD From: JONESD@kcgl1.eng.ohio-state.edu (David Jones) Newsgroups: comp.sys.dec,comp.os.vms Subject: Re: Qsort problem in DEC C Date: 3 Feb 1995 18:59:49 GMT Organization: The Ohio State University Message-ID: <3gtuf5$i1u@charm.magnus.acs.ohio-state.edu> References: NNTP-Posting-Host: kcgl1.eng.ohio-state.edu Xref: nntp.gmd.de comp.sys.dec:21516 comp.os.vms:64110 In article , lloyd-dr@nlvvax.llnl.egg.nv.doe.gov (David Lloyd) writes: > All right, I've apparently gone brain-dead, but I cannot for the life of me >get the following C example to compile with DEC C 4.0 under OpenVMS/VAX V6.1. > I get the warning message (between the dashed lines) that says (to me anyway) >"a" is not compatible with "a". Can anyone tell me where my programming and/or >linguistic skills left the room (with my sanity not far behind)? > >/* Program that does no useful work */ > >#include > >int compare (int *a, int *b) >{ > if (a < b) return(-1); > if (a == b) return(0); > if (a > b) return(1); >} > >void main(int argc, char** argv) >{ > > int intarray[10] = {4,3,6,2,1,7,9,8,3,1}; > > qsort(intarray, 10, sizeof(int), compare); > > return; >} The stdlib header file defines the last argument to qsort as a pointer to a funtion that take arguments (const void *, const void *). The compiler complains because you are passing a function with arguments (int *, int *). One workaround is to add the declaration "int compare();" to your main() function, the old fashioned function declaration disables the type checking on the arguments. BTW, the compare() routine in your sample is going to compare the addresses of the data items, not the values. David L. Jones | Phone: (614) 292-6929 Ohio State Unviversity | Internet: 2070 Neil Ave. Rm. 122 | jonesd@kcgl1.eng.ohio-state.edu Columbus, OH 43210 | vman+@osu.edu Disclaimer: Dogs can't tell it's not bacon.