PROTOBUF_C_OFFSETOF -> offsetof

offsetof() conforms to the C89 standard, just call it directly.
This commit is contained in:
Robert Edmonds 2014-06-04 17:28:51 -04:00
parent a1fa70c9b7
commit c96fee16c2
2 changed files with 3 additions and 5 deletions

View File

@ -53,8 +53,6 @@
# define PROTOBUF_C_DEPRECATED
#endif
#define PROTOBUF_C_OFFSETOF(struct, member) offsetof(struct, member)
#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB)
# ifdef PROTOBUF_C_EXPORT
# define PROTOBUF_C_API __declspec(dllexport)

View File

@ -145,16 +145,16 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
break;
case FieldDescriptor::LABEL_OPTIONAL:
if (optional_uses_has) {
printer->Print(variables, " PROTOBUF_C_OFFSETOF($classname$, has_$name$),\n");
printer->Print(variables, " offsetof($classname$, has_$name$),\n");
} else {
printer->Print(variables, " 0, /* quantifier_offset */\n");
}
break;
case FieldDescriptor::LABEL_REPEATED:
printer->Print(variables, " PROTOBUF_C_OFFSETOF($classname$, n_$name$),\n");
printer->Print(variables, " offsetof($classname$, n_$name$),\n");
break;
}
printer->Print(variables, " PROTOBUF_C_OFFSETOF($classname$, $name$),\n");
printer->Print(variables, " offsetof($classname$, $name$),\n");
printer->Print(variables, " $descriptor_addr$,\n");
printer->Print(variables, " $default_value$,\n");
printer->Print(variables, " $flags$, /* flags */\n");