jaypipes
unread,Aug 26, 2008, 11:42:57 AM8/26/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Protocol Buffers, drizzle...@lists.launchpad.net
Hi!
The C++ code generator has a small bug that produces code that
produces warnings on some compilers when the -pedantic flag is
enabled. In particular, when an enum definition ends in a trailing
comma, a warning is thrown. Here is a patch to fix the small bug.
Thanks,
Jay Pipes
MySQL/Sun
diff -u for /src/google/protobuf/compiler/cpp/cpp_enum.cc:
--- cpp_enum.cc 2008-08-26 10:57:59.000000000 -0400
+++ cpp_enum.cc.bak 2008-08-26 10:58:16.000000000 -0400
@@ -57,7 +57,14 @@
vars["prefix"] = (descriptor_->containing_type() == NULL) ?
"" : classname_ + "_";
- printer->Print(vars, "$prefix$$name$ = $number$,\n");
+ const char* enum_output;
+ // A trailing comma is a pedantic warning on some C++ compilers
+ // and so we ensure that no trailing slash is present
+ if (i != (descriptor_->value_count() - 1))
+ enum_output = "$prefix$$name$ = $number$, \n";
+ else
+ enum_output = "$prefix$$name$ = $number$\n";
+ printer->Print(vars, enum_output);
if (descriptor_->value(i)->number() < min_value->number()) {
min_value = descriptor_->value(i);