Another attempt to make MSVC happy!
C89 requires variable declarations upfront.
This commit is contained in:
@@ -155,14 +155,17 @@ static naRef f_round(naContext c, naRef me, int argc, naRef* args)
|
|||||||
{
|
{
|
||||||
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
naRef a = naNumValue(argc > 0 ? args[0] : naNil());
|
||||||
naRef b = naNumValue(argc > 1 ? args[1] : naNil());
|
naRef b = naNumValue(argc > 1 ? args[1] : naNil());
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
double x,y;
|
||||||
|
#endif
|
||||||
if(naIsNil(a))
|
if(naIsNil(a))
|
||||||
naRuntimeError(c, "non numeric arguments to round()");
|
naRuntimeError(c, "non numeric arguments to round()");
|
||||||
if (naIsNil(b))
|
if (naIsNil(b))
|
||||||
b.num = 1.0;
|
b.num = 1.0;
|
||||||
|
|
||||||
#ifdef _MSC_VER // MSVC is not C99-compatible, no round() in math.h
|
#ifdef _MSC_VER // MSVC is not C99-compatible, no round() in math.h
|
||||||
double y = a.num / b.num;
|
y = a.num / b.num;
|
||||||
double x = floor(y + 0.5);
|
x = floor(y + 0.5);
|
||||||
#else
|
#else
|
||||||
double x = round(a.num / b.num);
|
double x = round(a.num / b.num);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user