problem with cc compiler

Guy Greenwald ggg at sunquest.UUCP
Fri Jul 28 05:23:43 AEST 1989


In article <4935 at alvin.mcnc.org>, spl at mcnc.org (Steve Lamont) writes:
> Suppose that I wish to implement my own math library function, say sin() or
> cos(), for whatever reason, in a large pre-existing piece of code that I don't
> want to fiddle too much with.  How would I do this, then?

Declare the routine name before it is invoked, then define the routine to be
static. Here's an example:

main()
{
	/* Declare the function here */
	double sin();
	double x, something;

	/* ... code ... */

	x = sin(something);
}

static double sin(angle)
double angle;
{
	double value;

	/* Steve's slick sine calculation */
	return value;
}

It is the combination of the static definition and the declaration before use
that avoids the problem with the duplicate name in the run-time library.



More information about the Comp.lang.c mailing list