From ccc11678c734a8c52bc025b2b4c1b21e5f12abc7 Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Tue, 28 Apr 2009 01:48:06 +0000 Subject: [PATCH] Make building libprotobuf as a DLL work again. --- .../protobuf/compiler/cpp/cpp_message.cc | 8 +++-- src/google/protobuf/descriptor.pb.h | 36 +++++++++---------- src/google/protobuf/extension_set.h | 2 +- .../protobuf/generated_message_reflection.h | 5 ++- src/google/protobuf/repeated_field.h | 1 - src/google/protobuf/stubs/once.h | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 44546bd0..c5506699 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -424,10 +424,12 @@ GenerateClassDefinition(io::Printer* printer) { // Declare AddDescriptors() and BuildDescriptors() as friends so that they // can assign private static variables like default_instance_ and reflection_. printer->Print( - "friend void $adddescriptorsname$();\n" - "friend void $assigndescriptorsname$();\n", + "friend void $dllexport_decl$ $adddescriptorsname$();\n", + "dllexport_decl", dllexport_decl_, "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name()), + GlobalAddDescriptorsName(descriptor_->file()->name())); + printer->Print( + "friend void $assigndescriptorsname$();\n", "assigndescriptorsname", GlobalAssignDescriptorsName(descriptor_->file()->name())); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 96ccdea0..7512e407 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -208,7 +208,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -379,7 +379,7 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto > service_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; ::google::protobuf::FileOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; @@ -473,7 +473,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto ::google::protobuf::int32 start_; ::google::protobuf::int32 end_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -628,7 +628,7 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message { ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange > extension_range_; ::google::protobuf::MessageOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; @@ -847,7 +847,7 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa ::std::string* default_value_; static const ::std::string _default_default_value_; ::google::protobuf::FieldOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; @@ -956,7 +956,7 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag static const ::std::string _default_name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; ::google::protobuf::EnumOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1062,7 +1062,7 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const ::std::string _default_name_; ::google::protobuf::int32 number_; ::google::protobuf::EnumValueOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1171,7 +1171,7 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes static const ::std::string _default_name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; ::google::protobuf::ServiceOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1293,7 +1293,7 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess ::std::string* output_type_; static const ::std::string _default_output_type_; ::google::protobuf::MethodOptions* options_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -1446,7 +1446,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { bool java_multiple_files_; int optimize_for_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -1545,7 +1545,7 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message { bool message_set_wire_format_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -1694,7 +1694,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { ::std::string* experimental_map_key_; static const ::std::string _default_experimental_map_key_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -1785,7 +1785,7 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -1876,7 +1876,7 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -1967,7 +1967,7 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -2058,7 +2058,7 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -2156,7 +2156,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu ::std::string* name_part_; static const ::std::string _default_name_part_; bool is_extension_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -2295,7 +2295,7 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag double double_value_; ::std::string* string_value_; static const ::std::string _default_string_value_; - friend void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index c23dc2b0..a99b17cb 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -619,7 +619,7 @@ class RepeatedMessageTypeTraits { template -class LIBPROTOBUF_EXPORT ExtensionIdentifier { +class ExtensionIdentifier { public: typedef TypeTraitsType TypeTraits; typedef ExtendeeType Extendee; diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 8f1c9cfc..44231c6b 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -387,12 +387,11 @@ inline To dynamic_cast_if_available(From from) { // This is slightly complicated because small strings store their data within // the string object but large strings do not. LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); -int StringSpaceUsedExcludingSelf(const string& str); // Helper for EnumType_Parse functions: try to parse the string 'name' as an // enum name of the given type, returning true and filling in value on success, // or returning false and leaving value unchanged on failure. -bool ParseNamedEnum(const EnumDescriptor* descriptor, +LIBPROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor, const string& name, int* value); @@ -409,7 +408,7 @@ bool ParseNamedEnum(const EnumDescriptor* descriptor, // Just a wrapper around printing the name of a value. The main point of this // function is not to be inlined, so that you can do this without including // descriptor.h. -const string& NameOfEnum(const EnumDescriptor* descriptor, int value); +LIBPROTOBUF_EXPORT const string& NameOfEnum(const EnumDescriptor* descriptor, int value); } // namespace internal diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 8d5dc480..e12224fb 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -94,7 +94,6 @@ class LIBPROTOBUF_EXPORT GenericRepeatedField { // We need this (from generated_message_reflection.cc). LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); -int StringSpaceUsedExcludingSelf(const string& str); } // namespace internal diff --git a/src/google/protobuf/stubs/once.h b/src/google/protobuf/stubs/once.h index 58f1ea91..61c5f362 100644 --- a/src/google/protobuf/stubs/once.h +++ b/src/google/protobuf/stubs/once.h @@ -85,7 +85,7 @@ namespace protobuf { struct GoogleOnceInternal; -struct GoogleOnceType { +struct LIBPROTOBUF_EXPORT GoogleOnceType { GoogleOnceType(); void Init(void (*init_func)());