Xref: utzoo comp.lang.c:15690 comp.sys.ibm.pc:23550 Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!nosc!ucsd!rutgers!mailrus!ncar!tank!shamash!com50!pai!erc From: erc@pai.UUCP (Eric Johnson) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: using floats in functional prototypes Summary: I had much the same problem Keywords: float, MS-C 5.1, QC, Turbo C, Help Please! Message-ID: <365@pai.UUCP> Date: 20 Jan 89 15:15:41 GMT References: <1989Jan18.092522.14499@gpu.utcs.toronto.edu> Organization: Prime Automation, Inc., Burnsville, MN Lines: 139 [...] In article <1989Jan18.092522.14499@gpu.utcs.toronto.edu>, romwa@gpu.utcs.toronto.edu (Royal Ontario Museum) writes: > I am having some problems with using float's in functional > prototypes and am hoping that someone out there in netland can > help me out. The problem seems to be isolated to float types > and not to any other types. The examples below give the gist > of it. Tst2.c has a function "afunc" with one parameter. > When I compile the two files, I get a warning that the type of > the argument in the prototype doesn't match the declaration > (??). I experimented with this example a bit on a couple > of compilers and each time the warnings come out. What is > more disconcerting is that flt_val inside afunc isn't 6.5 but > some bizarre value. > A couple of other observations are that by changing > the type to be double made everything work, and by removing > the prototypes made everything work. Since MS-C 5.1, QuickC, > and Turbo C give similar results I assume it is something > about C that I don't understand. > advTHANKSance > Totally Perplexed, > > Pavneet Arora > ...!utgpu!rom!pavneet > > Royal Ontario Museum > 100 Queen's Park > Toronto, Ontario > M5S 2C6 > (416) 585-5626 I, too, had problems using a float in a function prototype for MS C 5.1. I recently upgraded from 4.0 to 5.1 and code that worked in 4.0, using the float in a prototype, failed in 5.1. If I remember correctly, the 5.1 compiler gave a warning message for the prototype. The fix: I removed the prototype and everything was hunky-dory. The problem is that this defeats the whole idea of using prototypes in the first place. It is interesting that you state the problem appears in both Borland's and Microsoft's compilers (we were thinking of switching to Turbo C, I guess we won't now). If anyone has a code section using a float in a prototype that works under MS C 5.1, I would appreciate the example code. I may be doing something wrong and I certainly wouldn't mind a constructive correction. In my case, we used something like: (I may have typed this in wrong, so no flames, please) int foo( float /* f */, int /* i */, int /* j */ ); as the prototype and int foo( f, i, j ) float f; int i; int j; { /* ... */ } as the function. This seemed to cause great problems, as the float value f never seemed to have the correct value upon entry to the function. This is no fun. Again, removing the prototype seemed to solve the problem. Does anyone have any ideas? I would appreciate any, although dumping the PC and getting a real computer is not really an option, no matter how much I'd like to do that. Thanks, -Eric [ Pavneet Arora's examples of the problem follow ] > > ---------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; > } -- Eric F. Johnson | Phone +1 612-894-0313 | Are we Prime Automation,Inc | UUCP: bungia!pai!erc | having 12201 Wood Lake Drive | UUCP: sun!tundra!pai!erc | fun Burnsville, MN 55337 USA | DOMAIN: erc@pai.mn.org | yet?