Date: Thu, 26 Feb 1998 11:38:51 -0600 From: Steve Price <sprice@hiwaay.net> To: "Aryeh M. Friedman" <aryeh@void.rad-inet.com> Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: misc/5856 Message-ID: <34F5A8AB.3D0D0DF2@hiwaay.net> References: <199802261702.JAA16425@void.rad-inet.com>
index | next in thread | previous in thread | raw e-mail
Aryeh M. Friedman wrote:
>
> This should be better doced in various places since I used to k&r where
> if no proto for a lib is found it assumes it is the same ret type as ther
> caller "expects" it to be
> ./
I'm pretty sure this is not the case. In K&R style code you
will generally see something like the following:
main() {
double atof(), foo;
foo = atof("1.345");
printf("%f", foo);
return 0;
}
Which does indeed work as expected.
What may be confusing you is that in the absence of a declaration
a K&R compiler will assume that the return type is int, just as
it does with main function above. So what you say will appear
true in every instance of a function that truly returns an int.
So in your example the absence of a declaration for atof causes
the compiler to assume atof returns an int which it in term tries
to convert to a double and assign to foo. In C this would be
equivalent to something like:
foo = (double)((int)atof("1.345"));
Steve
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34F5A8AB.3D0D0DF2>
