DragonFly BSD
DragonFly users List (threaded) for 2010-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: tgamma function in math library

From: Karthik Subramanian <karthik301176@xxxxxxxxx>
Date: Fri, 1 Jan 2010 23:03:19 +0530

On Fri, Jan 1, 2010 at 10:52 PM, Pierre Abbat <phma@phma.optus.nu> wrote:
> I just copied one of my programming projects to the laptop and attempted to
> compile it. The compiler bombed out on the line:
>  denom=tgamma(sh);
> According to the man page for gamma on Linux:
>   *BSD version
>       4.4BSD and FreeBSD libm have a gamma() function that computes the Gamma
>       function, as one would expect.
>   glibc version
>       Glibc has a gamma() function that is equivalent to  lgamma()  and  com‐
>       putes  the  natural logarithm of the Gamma function.  (This is for com‐
>       patibility reasons only.  Don’t use this function.)
> How should I write the program so that it uses tgamma() on Linux and gamma()
> on DragonFly?
> Pierre
> --
> La sal en el mar es más que en la sangre.
> Le sel dans la mer est plus que dans le sang.

Perhaps you could write a wrapper called gamma() that does something like this:

struct    utsname *ub;

/* malloc, etc. */

if(uname(ub)) {

if (strcmp(ub->sysname, "Linux") {
} else {

You could also go the #ifdef LINUX route - in which case you need to
make sure to define LINUX
when compiling your code on linux.

There are probably better ways of doing this, I'll leave it to more
knowledgeable people on the list
to answer :)


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]