简体   繁体   English

我可以同时在C ++和C中使用protobuf-c吗?

[英]can i use protobuf-c both in C++ and C?

i'm new one to protobuf-c i have altered protobuf-c client and server example program as per my requirement and i got this program through this link 我是protobuf-c的新手,我已根据我的要求更改了protobuf-c客户端和服务器示例程序,并通过此链接获得了此程序

code.google.com/p/protobuf-c/wiki/RPC_Example code.google.com/p/protobuf-c/wiki/RPC_Example

now i have to write server side programing in c++ and i want to use the client side program in c itself this my new requirement 现在我必须用C ++编写服务器端编程,并且我想在C本身中使用客户端程序,这是我的新要求

can any one please help me how to use the .h and .c proto file that is compiled using protobuf-c in c++ server side program file 谁能帮我如何使用在C ++服务器端程序文件中使用protobuf-c编译的.h和.c proto文件
any suggestions will be appreciated 任何建议将不胜感激

As pointed by @Konrad Rudolph, the entire point of protobuf is to use same message format with different languages. 正如@Konrad Rudolph所指出的,protobuf的全部目的是使用具有不同语言的相同消息格式。 So, you do the following: 因此,您执行以下操作:

  1. Write your .proto file 编写您的.proto文件
  2. Compile this .proto file with protobuf-c for client code and with protobuf (protoc) for server code (that would be different classes, but same message format!) 使用protobuf-c来编译此.proto文件,以使用客户端代码,使用protobuf(protoc)来编译服务器代码(这将是不同的类,但是消息格式相同!)
  3. Link client code to protobuf-c and server code to protobuf 将客户端代码链接到protobuf-c,将服务器代码链接到protobuf

This will resolve your issue. 这样可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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