Commit 97e7ddc0 authored by senhalil's avatar senhalil Committed by Adam Cozzette

Small patch to handle -Wfloat-equal warnings

https://groups.google.com/d/msg/protobuf/H8_D1hfg3p4/A2oPHdfUAgAJ
parent 27228494
......@@ -177,6 +177,10 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields still have has_$name$() methods.
format("if ($prefix$has_$name$()) {\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE
|| field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
// Handle float comparison to prevent -Wfloat-equal warnings
format("if (!($prefix$$name$() <= 0 && $prefix$$name$() >= 0)) {\n");
} else {
format("if ($prefix$$name$() != 0) {\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment