Google protobuf を使用しようとしていますが、次の例があります。
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;
}
このコードを Visual Studio Express 2008 に実装しようとすると、次のエラーが発生します。
エラー C2873: 'google::protobuf': シンボルは using 宣言では使用できません
編集:「名前空間 google::protobuf; を使用する」場合 関数内では、エラーが発生しなくなりました。私が混乱しているのは、Google の例 (および "The C++ Programming Language" の Stroustrup の例) が示すように機能しないことです。