Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit the _raw_default_instance_ declaration when using DLL linkage. #17314

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/google/protobuf/compiler/cpp/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,18 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
$pbi$::ParseContext* ctx);
)cc");
}},
{"raw_default_instance",
[&] {
// We can't make a constexpr pointer to the global if we have DLL
// linkage so skip this. The fallback in
// `MessageLite::GetStrongPointerForType` will do the right thing in
// those platforms.
if (!options_.dllexport_decl.empty()) return;
p->Emit(R"cc(
static constexpr const void* _raw_default_instance_ =
&_$classname$_default_instance_;
)cc");
}},
{"decl_impl", [&] { GenerateImplDefinition(p); }},
{"classdata_type",
HasDescriptorMethods(descriptor_->file(), options_)
Expand Down Expand Up @@ -2062,8 +2074,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
$decl_data$;
$post_loop_handler$;

static constexpr const void* _raw_default_instance_ =
&_$classname$_default_instance_;
$raw_default_instance$;

friend class ::$proto_ns$::MessageLite;
friend class ::$proto_ns$::Arena;
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/compiler/java/java_features.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions src/google/protobuf/compiler/plugin.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/google/protobuf/cpp_features.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 0 additions & 66 deletions src/google/protobuf/descriptor.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading