Func Protos with K&R Func Defs

David Brooks dbrooks at osf.org
Tue Mar 5 02:17:50 AEST 1991


jik at athena.mit.edu (Jonathan I. Kamens) writes:
|>   Now, you may get lucky for a while any only run into compilers that leave
|> the same amount of space on the stack for chars and ints.  But eventually
|> you're going to run into a compiler that doesn't.  And you're going to lose.

For all the lambasting Jonathan has gotten, he speaks truth here
(although I would put "un" before "lucky").

I recently saw the dangerous situation referred to in previous posts:
some routines with narrow arguments, and an attempt to cover both
prototyping and non-prototyping compilers with #ifdefs.

So, player A compiles the library with prototypes. She hands the
binary to player B, who compiles an application without using
prototypes (because he's got an old compiler).  Potential chaos
results: the application widens its arguments and the library expects
them unwidened.

Unfortunately, the whole mess was tested with gcc as the prototyping
compiler, and our gcc was built so that it leaves the same amount of
space on the stack for ints and chars (I understand this is a gcc
configuration option).  So the chaos remained potential, and
unnoticed, until it met up with a customer whose compiler happened to
like saving space on the stack.

This was not nice from a customer service standpoint.  There's a moral
here somewhere; maybe it's "read the FAQ".
-- 
David Brooks				dbrooks at osf.org
Systems Engineering, OSF		uunet!osf.org!dbrooks
"It's not easy, but it is simple."



More information about the Comp.lang.c mailing list