Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucbvax!hplabs!hp-pcd!hpcvia!brianh From: brianh@hpcvia.CV.HP.COM (brian_helterline) Newsgroups: comp.lang.c Subject: Re: legal ANSI prototype? Message-ID: <31530017@hpcvia.CV.HP.COM> Date: 30 Aug 90 15:15:57 GMT References: <31530015@hpcvia.CV.HP.COM> Organization: Hewlett-Packard Co., Corvallis, Oregon Lines: 45 >I have a question regarding the ANSI interpretation of a prototype >declaration. My compiler accepts it, but a pc-lint program does not. >I am interested in knowing which one is wrong. Here it is: >extern intSomeFunction( int ); >int main( void ); >int main( void ) >{ > int i = SomeFunction( 5 ); > return 0; >} >MSC takes this just fine but my pc-lint complains that SomeFunction >is called without a prototype being in scope. If I add a space in the >prototype, then everybody is happy. My question is > 1) is that prototype legal ANSI? > 2) Am I just lucky that MSC accepts it? > 3) Is my pc-lint broken because it misses it? >As to the reason why it is like that, some software I purchased the >following for prototypes: >#define IMPORT( t ) extern t >IMPORT( int )SomeFunction( int ); >.... First of all, thanks to all who responded to my note. I have since figured it exactly what is going on. When MSC preprocesses the IMPORT( int )SomeFunction( int ), it does add a space to get extern int SomeFunction( int ) _BUT_ if you preprocess to a file, the space is _NOT_ there and your preprocess file is no longer equivalent to your source code. My pc-lint program _DOES NOT_ add the space when it expands the macro so the function prototype is different that what it should be with ANSI C. As a side question, if you preprocess a source file to another file, is that file required to compile the same as the source file? I remember seeing some discussion on the net about it but I can't remember.