简体   繁体   中英

Google Protocol Buffers. C++ error: 'protobuf' does not name a type

I have the following code which I'm really struggling to compile:

#include <stdio.h>
#include <stdlib.h>
#include "test.pb.h"

using namespace google::protobuf;
using namespace std;


protobuf::RpcChannel* channel;   //error on this line!

I keep getting this 'protobuf' does not name a type error. I have no idea how to fix this ;(

Any insight greatly appreciated.

Many thanks in advance,

There is no protobuf namespace, since you did using namespace google::protobuf (which you shouldn't). Do namespace protobuf = google::protobuf instead.

您需要在使用RpcChannel的文件中包含#include“ google \\ protobuf \\ service.h”,而不是在标题中。

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