-
Notifications
You must be signed in to change notification settings - Fork 721
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
Add support for "optional" field for proto3 files #476
Comments
Before updating the generator to have |
This patch is obtained from the issue protobuf-c#476. The official documentation is: https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md Signed-off-by: Hiroshi Hatake <hatake@calyptia.com>
This patch is obtained from the issue protobuf-c#476. The official documentation is: https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md Signed-off-by: Hiroshi Hatake <hatake@calyptia.com>
Hi,
In file included from protoc-c/c_generator.cc:63:0: |
Any progress? |
Hi, I just want to mention I ran into this problem trying to compile the opentelemetry protobufs. Specifically it seems it's the metrics protobufs that trigger this: I assume it's this section:
|
Incorporating this change fixes the issue of not being able to use "optional" with "proto3" syntax but the generated C structs don't have the "has_field" members. |
Hi @edmonds Looks like v1.5.0 does not support "optional" field for proto3 files |
Any progress on adding support for optional fields for proto3? |
When there is a proto3 file which uses
optional
field, then protoc command throws an error.example.proto:
Command:
Error:
Solution:
Open
/protobuf-c-1.4.0/protoc-c/c_generator.h
and add the following lines inside CGenerator class: (Refer this https://chromium.googlesource.com/external/github.com/protocolbuffers/protobuf/+/refs/heads/master/docs/implementing_proto3_presence.md)Finally,
the CGenerator class inside
c_generator.h
should look like this:At last,
you need to re-install protobuf-c,
go to protobuf-c-1.4.0 directory and run the installation command:
./autogen.sh && ./configure && make && make install
Please add this support into the source code.
The text was updated successfully, but these errors were encountered: