Просмотр исходного кода

C++: export _xxx_default_instance_ symbols

_xxx_default_instance_ symbols are used in inline functions. We have
to export them to avoid undefined reference link errors.
Julien Brianceau 8 лет назад
Родитель
Сommit
b1295eeffb
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      src/google/protobuf/compiler/cpp/cpp_file.cc

+ 6 - 3
src/google/protobuf/compiler/cpp/cpp_file.cc

@@ -403,7 +403,7 @@ class FileGenerator::ForwardDeclarations {
   std::map<string, const Descriptor*>& classes() { return classes_; }
   std::map<string, const Descriptor*>& classes() { return classes_; }
   std::map<string, const EnumDescriptor*>& enums() { return enums_; }
   std::map<string, const EnumDescriptor*>& enums() { return enums_; }
 
 
-  void Print(io::Printer* printer) const {
+  void Print(io::Printer* printer, const Options& options) const {
     for (std::map<string, const EnumDescriptor *>::const_iterator
     for (std::map<string, const EnumDescriptor *>::const_iterator
              it = enums_.begin(),
              it = enums_.begin(),
              end = enums_.end();
              end = enums_.end();
@@ -422,8 +422,11 @@ class FileGenerator::ForwardDeclarations {
 
 
       printer->Print(
       printer->Print(
           "class $classname$DefaultTypeInternal;\n"
           "class $classname$DefaultTypeInternal;\n"
+          "$dllexport_decl$"
           "extern $classname$DefaultTypeInternal "
           "extern $classname$DefaultTypeInternal "
           "_$classname$_default_instance_;\n",  // NOLINT
           "_$classname$_default_instance_;\n",  // NOLINT
+          "dllexport_decl",
+          options.dllexport_decl.empty() ? "" : options.dllexport_decl + " ",
           "classname",
           "classname",
           it->first);
           it->first);
     }
     }
@@ -433,7 +436,7 @@ class FileGenerator::ForwardDeclarations {
          it != end; ++it) {
          it != end; ++it) {
       printer->Print("namespace $nsname$ {\n",
       printer->Print("namespace $nsname$ {\n",
                      "nsname", it->first);
                      "nsname", it->first);
-      it->second->Print(printer);
+      it->second->Print(printer, options);
       printer->Print("}  // namespace $nsname$\n",
       printer->Print("}  // namespace $nsname$\n",
                      "nsname", it->first);
                      "nsname", it->first);
     }
     }
@@ -808,7 +811,7 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
     dependency.FillForwardDeclarations(&decls);
     dependency.FillForwardDeclarations(&decls);
   }
   }
   FillForwardDeclarations(&decls);
   FillForwardDeclarations(&decls);
-  decls.Print(printer);
+  decls.Print(printer, options_);
 }
 }
 
 
 void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {
 void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {