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

Call DescriptorPool::FindEnumValueByName in C++ don't work (return nullptr). #16476

Open
lhh2001 opened this issue Apr 11, 2024 · 0 comments
Open

Comments

@lhh2001
Copy link

lhh2001 commented Apr 11, 2024

I have a proto file like this:

syntax = "proto3";

package test;

enum Foo {
  FOO_NONE = 0;
}

message Bar {
}

And I called FindEnumValueByName in cpp:

const auto EnumValueDesc = DescriptorPool::generated_pool()->FindEnumValueByName("test.FOO_NONE");  // EnumValueDesc = NULL

Then I got nullptr, but the wired thing is, if I called FindMessageTypeByName or FindEnumTypeByName on any type in the same package (not necessarily the very Foo enum type), it worked!

// Work, but WHYYYYYYYY?
const auto MessageDesc = DescriptorPool::generated_pool()->FindMessageTypeByName("test.Bar");
const auto EnumValueDesc = DescriptorPool::generated_pool()->FindEnumValueByName("test.FOO_NONE");
// Also work.
const auto EnumDesc = DescriptorPool::generated_pool()->FindEnumTypeByName("test.Foo");
const auto EnumValueDesc = DescriptorPool::generated_pool()->FindEnumValueByName("test.FOO_NONE");

Maybe it's some kind of bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant