[2530] in Kerberos_V5_Development
Prototype hell
daemon@ATHENA.MIT.EDU (Ken Hornstein)
Thu Oct 9 15:27:58 1997
To: krbdev@MIT.EDU
Date: Thu, 09 Oct 1997 15:25:12 -0400
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
Okay, I've heard two different schools of thought here, and I'm interested
in what other people have to say.
The Kerberos 5 distribution is littered with function prototypes that
end up being (if __STDC__ is defined):
int foo(int, int, int);
But the actual function declaration is:
int foo(a, b, c)
int a;
int b;
int c;
{
...
Now, this isn't a problem if we assume "all the world's an int", but if you're
porting to a machine that has it's 32 bit type as a _short_, then there are
some problems. Specifically, the one machine I'm trying to port Kerberos
to has a 32-bit short (well, it doesn't, really, but that's a whole
_other_ problem), so anything that uses krb5_int32 craps out the C compiler
on this system with an incorrect prototype error.
Now, I really don't understand the C specifiation that well, so I was
wondering .... who's at fault here? Kerberos, or the C compiler?
I've heard one set of arguments that say old-style function declarations
always get promoted to a int, which doesn't match a prototype of a short.
Is that correct? Pointers from the ANSI C standard would be appreciated,
as I could use it as ammo.
Should technically all of the prototypes be of the form:
int foo
#ifdef KRB5_PROTOTYPE
(int a, int b, int c)
#else
(a, b, c)
#endif
{
(Which, IIRC, is what X11 does)?
Right now I'm using -U__STDC__, but somehow I don't think that's the
right thing to do :-/
--Ken