🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #66

Re: extern double fabs(); standard conforming?

#66
From: Clive Feather
Date: Wed, 04 Nov 1992 12:21
28 lines
1450 bytes
In article <1992Nov3.005333.17727@Princeton.EDU> rhl@grendel.Princeton.EDU (Robert Lupton the Good) writes:
> Is the following Standard Conforming?
>    #include <math.h>
>    extern double sin();

No. Section 7.1.7 of the ISO standard:

| ... a library function should not be declared explicitly if its header
| is included.

> I'd have said yes (as the sin() merely says that I don't know about its
> arguments), but it is rejected by the IBM c89 compiler%
> % their math.h defines sin as
>	#define sin(x) __sin(x)

Which is why that restriction exists in the compiler. A more obvious
use of this is:

    #define malloc(s) (__using_D_malloc ? __D_malloc (s) : __malloc (s))
    #define free(p)   (__using_D_malloc ? __D_free (p)   : __free (p)  )

where the D malloc family is some special debugging malloc.

-- 
Clive D.W. Feather     | IXI Limited         | If you lie to the compiler,
clive@x.co.uk          | Vision Park         | it will get its revenge.
Phone: +44 223 236 555 | Cambridge   CB4 4RZ |   - Henry Spencer
Fax:   +44 223 236 550 | United Kingdom      |
Technical Details
Message-ID: <1992Nov04.122136.22530@x.co.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!acorn!ixi!clive
References: <1992Nov3.005333.17727@Princeton.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!acorn!ixi!clive
From: clive@x.co.uk (Clive Feather)
Newsgroups: comp.std.c
Subject: Re: extern double fabs(); standard conforming?
Message-ID: <1992Nov04.122136.22530@x.co.uk>
Date: 4 Nov 92 12:21:36 GMT
References: <1992Nov3.005333.17727@Princeton.EDU>
Organization: IXI Limited, Cambridge, UK
Lines: 28