I am trying to use google protobuf and they have the following example:
using google::protobuf;
protobuf::RpcChannel* channel;
protobuf::RpcController* controller;
SearchService* service;
SearchRequest request;
SearchResponse response;
void DoSearch() {
// You provide classes MyRpcChannel and MyRpcController, which implement
// the abstract interfaces protobuf::RpcChannel and protobuf::RpcController.
channel = new MyRpcChannel("somehost.example.com:1234");
controller = new MyRpcController;
// The protocol compiler generates the SearchService class based on the
// definition given above.
service = new SearchService::Stub(channel);
// Set up the request.
request.set_query("protocol buffers");
// Execute the RPC.
service->Search(controller, request, response, protobuf::NewCallback(&Done));
}
void Done() {
delete service;
delete channel;
delete controller;
}
The error I am getting when I try to implement this code in Visual Studio Express 2008 is:
error C2873: 'google::protobuf' : symbol cannot be used in a using-declaration
Edit: When I do "using namespace google::protobuf;" inside of a function it no longer gives me the error. What I'm confused about is that it doesn't work the way that Google's example (and Stroustrup's in "The C++ Programming Language") seem to indicate.