What is the #ifdef equivalent in protobuf messages? I don't find anything in language guide https://developers.google.com/protocol-buffers/docs/proto
There is none built into the Protobuf language itself, but you could of course run the C preprocessor over your .proto
files before passing them to protoc
. On Unix systems:
cpp -P src.proto > preprocessed.proto
protoc preprocessed.proto
cpp
(which comes with your C compiler) will evaluate #ifdef
and other C preprocessor directives (anything starting with #
) and output a new file with the results.
(The -P
option prevents the preprocessor from outputting debug info directives intended for the C compiler, which protoc
wouldn't understand.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With