diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/objectivec/objectivec_file.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 878a3743..7ad127bb 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -51,10 +51,8 @@ namespace objectivec { namespace { -// This is also found in GPBBootstrap.h, and needs to be kept in sync. It -// is the version check done to ensure generated code works with the current -// runtime being used. -const int32 GOOGLE_PROTOBUF_OBJC_GEN_VERSION = 30002; +// This is also found in GPBBootstrap.h, and needs to be kept in sync. +const int32 GOOGLE_PROTOBUF_OBJC_VERSION = 30002; const char* kHeaderExtension = ".pbobjc.h"; @@ -192,13 +190,19 @@ void FileGenerator::GenerateHeader(io::Printer *printer) { // Add some verification that the generated code matches the source the // code is being compiled with. + // NOTE: This captures the raw numeric values at the time the generator was + // compiled, since that will be the versions for the ObjC runtime at that + // time. The constants in the generated code will then get their values at + // at compile time (so checking against the headers being used to compile). printer->Print( - "#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != $protoc_gen_objc_version$\n" - "#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.\n" + "#if GOOGLE_PROTOBUF_OBJC_VERSION < $google_protobuf_objc_version$\n" + "#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.\n" + "#endif\n" + "#if $google_protobuf_objc_version$ < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION\n" + "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n" "#endif\n" "\n", - "protoc_gen_objc_version", - SimpleItoa(GOOGLE_PROTOBUF_OBJC_GEN_VERSION)); + "google_protobuf_objc_version", SimpleItoa(GOOGLE_PROTOBUF_OBJC_VERSION)); // #import any headers for "public imports" in the proto file. { @@ -392,7 +396,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { " // about thread safety and initialization of registry.\n" " static GPBExtensionRegistry* registry = nil;\n" " if (!registry) {\n" - " GPBDebugCheckRuntimeVersion();\n" + " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n" " registry = [[GPBExtensionRegistry alloc] init];\n"); printer->Indent(); @@ -487,7 +491,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) { " // about thread safety of the singleton.\n" " static GPBFileDescriptor *descriptor = NULL;\n" " if (!descriptor) {\n" - " GPBDebugCheckRuntimeVersion();\n"); + " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"); if (vars["objc_prefix"].size() > 0) { printer->Print( vars, |