Information hiding

Karl Heuer karl at haddock.ISC.COM
Wed Apr 27 14:34:16 AEST 1988


In article <10576 at steinmetz.ge.com> davidsen at steinmetz.ge.com (William E. Davidsen Jr) writes:
>One of the things which bothers me about the C language is that many (most)
>compilers, and lint, complain about taking the address on an array.

Fixed in dpANS.

>Not that it isn't redundant,

Actually it's not redundant -- on compilers that do it right, "a" and "&a[0]"
are equivalent and have type "sometype *", but "&a" has type "sometype (*)[]".
(If cast to a common compatible type, they will be equal, however.)

>but there is a good reason for allowing it...: information hiding.

Agreed.  It's because of this botch that "jmp_buf" is required to be an array
type: it's passed by value to setjmp.  Ideally, the argument of setjmp should
be of type "jmp_buf *".

>NOTE: This applies to addresses of procedures, too, in some cases.

It's not clear whether ANSI C implementations will issue warnings for "pf=&f".
I hope not; I think that syntax makes more sense than "pf=f", and would use it
exclusively if not for the stupid warning on PCC-based compilers.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list