简体   繁体   中英

how to compile .proto + .options file using nanopb

i wrote an .options file and placed it in the same directory as the .proto file. then, I tried to compile it (using nanopb compiler) by using the command

generator-bin/protoc --nanopb_out=. message.proto -s message.options

and got this error:

Unknown flag: -s

so what am I doing wrong? do I need to import my options file in the .proto file? is there anything else I should do to make it work?

Google's protoc has a special syntax for passing options to the plugins. The plugin options are put as argument to nanopb_out and separated from the actual destination path by colon ( : ).

generator-bin/protoc '--nanopb_out=-v -f message.options:.' message.proto

However, if your .options file has the same name as the .proto and is in the same directory, nanopb plugin should automatically find and use it.

Also note that the -s flag to nanopb expects a pair of settings on the command line, while -f takes a filename. Specifying -v is also useful to get detailed messages whether it loaded the options file or not. You can get full list of command line options by running:

generator-bin/nanopb_generator --help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM