Subject: Re: rpcgen and -fshort-enums round 2
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-toolchain
Date: 02/19/2002 22:46:11
>> and if you __P() the prototype away, you've just got a plain
>> old-style everything.
> I'm not sure what you mean there.

I mean that if you write an old-style definition and what looks like a
prototyped declaration but using __P(), and then make __P() turn into
() instead of a real prototype (so that it is really just a comment,
spelled in an unusual way), then you've got exactly as much help from
the compiler as if you didn't even appear to be trying for prototypes.

> In an ideal portable C program you will [...]

You and I obviously have very different ideas of "ideal" in this
connection.  Rather than get into yet another interminable discussion
with you, I will leave this part of it at that.

>> In gcc, an old-style definition with a previous prototype
>> declaration is silently converted to a new-style definition, so you
>> have the same incompatability you do with a wholly new-style
>> approach.
> Yes, that's right.  The same should happen for any ANSI C compiler.

The gcc documentation implies otherwise.  For full details, see the
texinfo @node called "Function Prototypes" in extend.texi; to
summarize, it claims that

	int isroot(short);

is incompatible with

	int isroot(x)
	short x;
	{ ... }

because the latter actually declares x as int; the texinfo file claims
that gcc's causing the prototype to handle isroot as if it had been
written "int isroot(short x)" is an extension.

Since I don't have a copy of the Standard, I can't offer any more
informed an opinion than that, so I'll bow out of this one and let you
fight it out with the gcc doco.

> Function prototypes are really just a crutch for lazy programmers
> (and no C programmer can ever afford to be lazy, ANSI-C or not!).

Function prototypes _can be_ just a crutch for lazy programmers.

They can also be a valuable and powerful tool for creating good code
when used with intelligence, discipline, and an understanding of what
they do (and perhaps more importantly, don't do).

Just like the rest of C - both Classic and ANSI.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B