Manual may mislead many mighty men.

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Mar 18 12:52:52 AEST 1990


In article <24407 at uhnix1.uh.edu> rr at cs.uh.edu (Ravi Ramachandran) writes:
>On pg. 373 he says, "...oplist is a pointer to an array of semaphore
>operations ..." 
>(It should be " oplist is an array of ..." ?)

I think this confusion occurred because of the way that C arrays have
traditionally been botched.  The correct type for the second argument
to semop() is (struct sembuf *), and it is expected to point to THE
FIRST ELEMENT OF a user-defined array of semaphore operation structures.
Because of the C array botch, most documentation (e.g. SVID3) has been
calling this a "pointer to a user-defined array of ...".  In pre-ANSI C
implementations, it was not usually possible to construct a pointer to
an array; an attempt to do so would be coerced by the compiler into a
pointer to the array's first element.  In ANSI C the distinction is
important, and the words "the first element of" should be added to the
documentation.

Note that your suggested fix is wrong; a function parameter cannot have
array type in either old or new C.



More information about the Comp.unix.wizards mailing list