diff options
author | Karol Ostrovsky <karol.ostrovsky@gmail.com> | 2015-06-29 16:13:33 +0200 |
---|---|---|
committer | Karol Ostrovsky <karol.ostrovsky@gmail.com> | 2015-07-01 10:09:41 +0200 |
commit | ee35402244fc463cedc470baa0f5f1a6080d905d (patch) | |
tree | 8a127c0f8762f5b07129d97dd2fba584fef20431 /src/google/protobuf/compiler/csharp/csharp_field_base.cc | |
parent | d40a0db202433ba002a3e104165d4414e8929432 (diff) |
MinGW64+MSYS2 compilation issues and portable isnan using MathLimits
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_field_base.cc')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_field_base.cc | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index c3ce426b..4c6a3d72 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -38,6 +38,7 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> #include <google/protobuf/compiler/csharp/csharp_field_base.h> #include <google/protobuf/compiler/csharp/csharp_helpers.h> @@ -248,11 +249,6 @@ bool FieldGeneratorBase::is_nullable_type() { } } -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - bool AllPrintableAscii(const std::string& text) { for(int i = 0; i < text.size(); i++) { if (text[i] < 0x20 || text[i] > 0x7e) { @@ -309,7 +305,7 @@ std::string FieldGeneratorBase::default_value() { return "double.PositiveInfinity"; } else if (value == -numeric_limits<double>::infinity()) { return "double.NegativeInfinity"; - } else if (IsNaN(value)) { + } else if (MathLimits<double>::IsNaN(value)) { return "double.NaN"; } return SimpleDtoa(value) + "D"; @@ -320,7 +316,7 @@ std::string FieldGeneratorBase::default_value() { return "float.PositiveInfinity"; } else if (value == -numeric_limits<float>::infinity()) { return "float.NegativeInfinity"; - } else if (IsNaN(value)) { + } else if (MathLimits<float>::IsNaN(value)) { return "float.NaN"; } return SimpleFtoa(value) + "F"; |