diff --git a/protoc-c/c_file.cc b/protoc-c/c_file.cc index 59c1824..d211a3d 100644 --- a/protoc-c/c_file.cc +++ b/protoc-c/c_file.cc @@ -119,7 +119,11 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { int min_header_version = 1000000; #if defined(HAVE_PROTO3) +# if GOOGLE_PROTOBUF_VERSION >= 4023000 + if (FileDescriptorLegacy(file_).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3) { +# else if (file_->syntax() == FileDescriptor::SYNTAX_PROTO3) { +#endif min_header_version = 1003000; } #endif diff --git a/protoc-c/c_helpers.h b/protoc-c/c_helpers.h index adc7ee2..055528b 100644 --- a/protoc-c/c_helpers.h +++ b/protoc-c/c_helpers.h @@ -70,6 +70,10 @@ #include #include +#if GOOGLE_PROTOBUF_VERSION >= 4023000 +# include +#endif + namespace google { namespace protobuf { namespace compiler { @@ -172,7 +176,11 @@ int compare_name_indices_by_name(const void*, const void*); // This wrapper is needed to be able to compile against protobuf2. inline int FieldSyntax(const FieldDescriptor* field) { #ifdef HAVE_PROTO3 +# if GOOGLE_PROTOBUF_VERSION >= 4023000 + return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2; +# else return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2; +# endif #else return 2; #endif