Xref: utzoo comp.lang.c:15751 comp.sys.ibm.pc:23683 Path: utzoo!attcan!uunet!mcvax!ukc!warwick!geoff From: geoff@warwick.UUCP (Geoff Rimmer) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: using floats in functional prototypes Keywords: float, MS-C 5.1, QC, Turbo C, Help Please! Message-ID: <942@ubu.warwick.UUCP> Date: 23 Jan 89 07:59:25 GMT References: <1989Jan18.092522.14499@gpu.utcs.toronto.edu> Sender: news@warwick.UUCP Reply-To: geoff@emerald.UUCP (Geoff Rimmer) Organization: Computer Science, Warwick University, UK Lines: 70 In article <1989Jan18.092522.14499@gpu.utcs.toronto.edu> romwa@gpu.utcs.toronto.edu (Royal Ontario Museum) writes: >---------tst.c------------------------------------------------- > #include > > void afunc( float ); > > void main( void ) > { > float flt_val = 6.5; > > afunc( flt_val ); > } > > >---------tst2.c------------------------------------------------ > #include > > void afunc( float ); > > void afunc( flt_val ) > float flt_val; > > { > int i; > i = 3; > } The problem is that you are using the old way of defining the function afunc(). You should the new method: void afunc(float flt_val) { ... } BTW, rather than have to repeat the function prototype in both source files, put it once in tst2.h, and get both tst.c and tst2.c to #include "tst2.h". Finally, if you want to do a function prototype for a function with no arguments (e.g. main() in your example), the PROTOTYPE should have 'void' between the parentheses, but the DEFINITION shouldn't: e.g., rewriting your tst.c #include void afunc(float); void main(void); /* prototype */ void main() /* definition */ { float flt_val = 6.5; afunc( flt_val ); } ------------------------------------------------------------ Geoff Rimmer, Computer Science, Warwick University, England. geoff@uk.ac.warwick.emerald "Why don't we go out for just ONE drink?" "No. Because you know what would happen then, don't you?" "Lager Frenzie!" "And one thing you can't do after Lager Frenzie, is get up at 4.30 in the morning." "We could exercise restraint." "Yes, but then again in the real world, perhaps we couldn't!" - Filthy Rich and Catflap, 1986. ------------------------------------------------------------