Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.lang.c,comp.bugs.4bsd Subject: Re: Bad Pointer Declaration in 'scandir' Message-ID: <6145@mimsy.UUCP> Date: Sun, 5-Apr-87 07:55:50 EST Article-I.D.: mimsy.6145 Posted: Sun Apr 5 07:55:50 1987 Date-Received: Sun, 5-Apr-87 21:47:25 EST References: <2479@dalcs.UUCP> <5916@mimsy.UUCP> <2491@dalcs.UUCP> <1575@dg_rtp.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 40 Xref: utgpu comp.lang.c:1474 comp.bugs.4bsd:272 This is getting out of hand, but I cannot let my reputation get tarnished here :-). In article <1575@dg_rtp.UUCP> throopw@dg_rtp.UUCP (Wayne Throop) writes: >... Unusual as it is for Chris to make a mistake, he has made a >doozy here (though an easy doozy to make, so to type). >In particular, the claim that *(*foo)[], which is a pointer to an array >of pointers, should be replaced by ***foo, which is a pointer to a >pointer (or an array of pointers) to a pointer (or an array of pointers) >is WRONG, WRONG, WRONG! I did not (or I hope I did not) make such a claim. Rather, my claim was that the type of `namelist' in scandir should have been (struct direct ***): not (struct direct **[]), as it was in the source and manual page; nor (struct direct *(*)[]), as was suggested in the first article with this title. So let us take a look at the top of scandir: scandir(dirname, namelist, select, dcomp) char *dirname; struct direct *(*namelist[]); /* the parentheses in the line above are unnecessary */ int (*select)(), (*dcomp)(); { ... Lo! Namelist is a *parameter*. And what happens with array declarations when they appear in parameter contexts? And (not that it is now necessary), as a coup de grace (where are the accents? there are no accents on my keyboard!), I quote from the comment immediately preceding the code to scandir() itself: Returns the number of entries and a pointer to a list of pointers to struct direct (through namelist). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu