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
Support custom options without optional keyword (proto3) #321
Comments
Hmm, extensions only exist for custom options in proto3, which is why by default it skips them. It's simple enough to allow extensions in proto3 mode in nanopb, but this wouldn't get you very far, because nanopb has no reflection mechanism that would let to access the actual option values. However adding real support for custom options seems like a reasonable idea. What would be your preferred way to access such options? I see two straightforward options:
#define Bar_value_foo_options_opt1 123 #define Bar_value_foo_options_opt2 "baz"
extern cost FooOptions Bar_value_foo_options; .. const FooOptions Bar_value_foo_options = {123, "baz"}; Of these, 1) seems to me like it would be more useful in most cases. |
I haven't tried with a proto2 file, so my guess was that it would work after added it in proto3 mode. It would be awesome if this could be added to nanopb! I personally prefer 2) as things are typed and can be more easily passed as a pointer, but I could live with both options. |
Would be really cool indeed. I also prefer option 2). |
Now we also need it in the C counterpart. |
Any plans to implement this? |
I do not currently have plans to do so. It is a relatively simple task (only generator code changes needed), and pull requests are welcome. |
When I use custom options in a proto3 file nanopb adds a note in the generated header file that they're not supported:
I would be awesome if those were supported as well.
Minimum (non-)working example:
The text was updated successfully, but these errors were encountered: