3.3 C Weirdness
Eric Pepke
pepke at gw.scri.fsu.edu
Tue Sep 25 01:25:51 AEST 1990
There is a weirdness in the C that comes with 3.3 when the -prototypes
argument is supplied.
I like to put prototypes in the .h file associated with each .c file, and
then use old style definitions in the .c file. That way, if I want to
compile on a 3030, I just hack out the prototypes and it compiles fine.
With the new C, however, I sometimes get some odd error messages of the
form
old/new style declaration and definition of <function name> argument <#>
mismatch: change the definition to the new (function prototype) style.
As far as I can tell, this does not in any way affect code generation;
everything compiles fine. It only seems to occur when the argument type
in the prototype is a different size from the type it is promoted to when
normally passed on the stack.
For example, an int is the same size as a long, and a short is shorter.
Integer arguments are normally passed as ints, so shorts and chars are
ordinarily promoted to ints when passed.
This fragment would compile fine:
void bork(int);
void bork(i)
int i;
{
}
These would fail:
void face(char);
void face(c)
char c;
{
}
void fat(short);
void fat(s)
short s;
{
}
However, both of these would work:
void face(char c)
{
}
void fat(short s)
{
}
This behavior puzzles me, because by the time the parser gets to the open
bracket, which is where the error is detected, it has enough semantic
information to do the right thing no matter whether new- or old-style
definitions are used. Selectively to reject old-style definitions seems
needlessly purist.
Does there exist a fix or workaround for this? I would call the hotline,
were it not for the difficulty in explaining things like this in detail
over the phone.
Eric Pepke INTERNET: pepke at gw.scri.fsu.edu
Supercomputer Computations Research Institute MFENET: pepke at fsu
Florida State University SPAN: scri::pepke
Tallahassee, FL 32306-4052 BITNET: pepke at fsu
Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.
More information about the Comp.sys.sgi
mailing list