Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uunet!ns-mx!ccad.uiowa.edu!cadsi From: cadsi@ccad.uiowa.edu (CADSI) Newsgroups: comp.os.msdos.programmer Subject: Re: Problem with BC++ and non-prototyped functions Message-ID: <1991Apr9.175029.9197@ccad.uiowa.edu> Date: 9 Apr 91 17:50:29 GMT References: Distribution: na Organization: CAD-Research, U. of Iowa, Iowa City, Iowa Lines: 23 From article , by greg@turbo.atl.ga.us (Greg Montgomery): > I'm having a little problem with BC++ and functions that I didn't use > the include files. For instance, I noticed using the fabs() function > would actually increase the variable I was getting the abs of by 90 > until I added a #include in the top of the .C file. > Why would this happen? I can't figure out why having a declaration (I > think that's the right word??) would affect how the function actually > works. I've noticed this a couple times tonight. I think the same thing > happened with atof(). Any ideas on this?? Is this a normal C happening > or a bug that needs to be reported to Borland? This is a standard C beginners problem. C assumes integer if not told otherwise. Thus, without the prototype in the math.h header file, atof is assumed to pass back an integer, not a double. In addition, without the prototype, the compiler will allow you to pass an integer to the function. Even uglier, since atof will read a double off the stack starting from where the integer was placed. |----------------------------------------------------------------------------| |Tom Hite | The views expressed by me | |Manager, Product development | are mine, not necessarily | |CADSI (Computer Aided Design Software Inc. | the views of CADSI. | |----------------------------------------------------------------------------|