Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!husc6!bacchus!rlk From: rlk@bacchus.UUCP Newsgroups: comp.lang.c,comp.bugs.4bsd Subject: Re: Bad Pointer Declaration in 'scandir' Message-ID: <412@bacchus.MIT.EDU> Date: Wed, 1-Apr-87 16:24:01 EST Article-I.D.: bacchus.412 Posted: Wed Apr 1 16:24:01 1987 Date-Received: Sat, 4-Apr-87 08:28:48 EST Sender: daemon@bacchus.MIT.EDU Reply-To: rlk@athena.MIT.EDU Organization: MIT Project Athena Lines: 41 Xref: utgpu comp.lang.c:1425 comp.bugs.4bsd:257 In article <2491@dalcs.UUCP> dalegass@dalcs.UUCP (Dale Gass) writes: ]Minor point: ] ]In article <5916@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: ]> >read] struct direct *(*namelist)[]; ]> ]> No: for there is no such thing. A declaration for a pointer to an ]> array must specify the size of the array. In fact, what both the ]> code and the manual *should* say is ]> ]> struct direct ***namelist; ] ]I disagree with this. I think a pointer to an array need not specify the ]array size. The compiler (all the one's I've dealt with) will allow this ]omission of array size. In many cases, it is required to be able to allow ]pointers to different size arrays being passed to a function. Conceivably, this need not be the case. In practice, sometimes it isn't (read: 80[123]?8[68]), although no one ever calls it that. Most compilers for this architecture set that I am familiar with require you to specify what "model" of code you are using, namely in terms of size of code, data, etc. The fact is, sometimes a pointer is 16 bits and sometimes it is 32 bits (20 bits, if you want to be clever). This could very easily depend on the size of an array. Now, a compiler writer might decide to be smart and have the compiler automatically select what "model" to use, dynamically. The compiler might want to optimize by using 16 bit addresses whenever possible; without knowing the size of an array, it might not know how big the pointer should be. Does the ANSI standard have anything to say to this issue? Not that I particularly care to defend this architecture (it's a kludgy way of extending the address space of a basically 16-bit address space, and it's only slightly more elegant than the bank switching things people did with Z80's and 6502's). It's just that conceivably a pointer to an array isn't just a pointer to an array. Robert^Z