[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MSVC compilation failure
From: |
David Bateman |
Subject: |
Re: MSVC compilation failure |
Date: |
Wed, 12 Dec 2007 16:52:09 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Michael Goffioul wrote:
> While trying to compile current CVS (and unfortunately, it also
> appears in the brand new 2.9.19 release), I found a compilation failure under
> MSVC in graphics.cc: "trunc" function is not provided by MSVC. This can
> be easily worked around by using
>
> #define trunc(x) (((x) < 0) ? ceil((x)) : floor((x)))
>
> The quick workaround is to put this define statement at the top of graphics.cc
> and surround it with ifdef. A more "long-term" solution would be to
> 1) add a check for trunc in configure.in (with checks for log2, exp2...)
> 2) add "double trunc(double a)" function in liboctave/lo-mappers.[h|cc]
> and export it (or lo-utils.[h|cc], or lo-specfun.[h|cc]); surround with
> #if !HAVE_TRUNC.
> 3) include the header used in 2) in graphics.cc
>
> I can provide a patch for either of the 2 solutions. Which one is preferred?
>
> Michael.
>
The best solution to me would be to add "trunc" to AC_CHECK_FUNCS in
configure.in and then add
double
xtrunc (double x)
{
#if defined (HAVE_TRUNC)
return trunc (x);
#else
return (((x) < 0) ? ceil((x)) : floor((x)));
#endif
}
to liboctave/lo-mappers.cc, and then use xtrunc for all uses of the
trunc function. At least is then consistent with other similar
functions.. Either that or just don't use trunc as the place where its
used it could be replaced with "ceil".
D.