From: James Turner Date: Wed, 9 Oct 2013 09:52:54 +0000 (+0200) Subject: Fix MSVC build, no C99 so no round(). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d148bdedcd3f665aa713f5eec10fa1fb603160ce;p=simgear.git Fix MSVC build, no C99 so no round(). (Doesn't use SGMisc::round, since Nasal is pure C) --- diff --git a/simgear/nasal/mathlib.c b/simgear/nasal/mathlib.c index fcf23e6e..b12bc830 100644 --- a/simgear/nasal/mathlib.c +++ b/simgear/nasal/mathlib.c @@ -159,8 +159,13 @@ static naRef f_round(naContext c, naRef me, int argc, naRef* args) naRuntimeError(c, "non numeric arguments to round()"); if (naIsNil(b)) b.num = 1.0; - + +#ifdef _MSC_VER // MSVC is not C99-compatible, no round() in math.h + double y = a.num / b.num; + double x = floor(y + 0.5); +#else double x = round(a.num / b.num); +#endif a.num = x * b.num; return VALIDATE(a);