From d148bdedcd3f665aa713f5eec10fa1fb603160ce Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 9 Oct 2013 11:52:54 +0200 Subject: [PATCH] Fix MSVC build, no C99 so no round(). (Doesn't use SGMisc::round, since Nasal is pure C) --- simgear/nasal/mathlib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); -- 2.39.5