Path: utzoo!attcan!uunet!mailrus!uflorida!mephisto!prism!sun13!gw.scri.fsu.edu!pepke From: pepke@gw.scri.fsu.edu (Eric Pepke) Newsgroups: comp.sys.sgi Subject: 3.3 C Weirdness Message-ID: <761@sun13.scri.fsu.edu> Date: 24 Sep 90 15:25:51 GMT Sender: news@sun13.scri.fsu.edu Organization: Florida State University, but I don't speak for them Lines: 74 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 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@gw.scri.fsu.edu Supercomputer Computations Research Institute MFENET: pepke@fsu Florida State University SPAN: scri::pepke Tallahassee, FL 32306-4052 BITNET: pepke@fsu Disclaimer: My employers seldom even LISTEN to my opinions. Meta-disclaimer: Any society that needs disclaimers has too many lawyers.