From fbfedcf0ac66647008cb02d83e9123ab1179cda4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 14 Jan 2013 15:16:20 -0800 Subject: [PATCH] Fix the issue with signbit in C++11. --- format.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/format.cc b/format.cc index eb76e02a..f43ddf18 100644 --- a/format.cc +++ b/format.cc @@ -31,10 +31,16 @@ #undef _SCL_SECURE_NO_WARNINGS #define _SCL_SECURE_NO_WARNINGS -#include "format.h" - #include +// Wrap signbit because when compiled in C++11 mode signbit is no longer a +// macro but a function defined in namespace std and the macro is undefined. +#ifndef _MSC_VER +inline int SignBit(double value) { return signbit(value); } +#endif + +#include "format.h" + #include #include #include @@ -85,7 +91,7 @@ char *FillPadding(char *buffer, } #ifdef _MSC_VER -int signbit(double value) { +int SignBit(double value) { if (value < 0) return 1; if (value == value) return 0; int dec = 0, sign = 0; @@ -188,9 +194,9 @@ void BasicFormatter::FormatDouble( } char sign = 0; - // Use signbit instead of value < 0 because the latter is always + // Use SignBit instead of value < 0 because the latter is always // false for NaN. - if (signbit(value)) { + if (SignBit(value)) { sign = '-'; value = -value; } else if (spec.sign_flag()) {