0

这是参考代码 http://pastebin.com/nr7wuxNA

我正在使用 mongo 的 C++ 驱动程序测试一些调用

它有效,除非我添加此行

obj.appendBinData( "binTest",sizeof(test), BinDataGeneral, test);

这是错误消息

ninexample.cpp: In function ‘int main(int, const char**)’:
ninexample.cpp:73:48: error: ‘BinDataGeneral’ was not declared in this scope
     obj.appendBinData( "binTest",sizeof(test), BinDataGeneral, test);
                                                ^
ninexample.cpp:73:48: note: suggested alternative:
In file included from /usr/include/mongo/db/jsobj.h:34:0,
                 from /usr/include/mongo/client/dbclientinterface.h:25,
                 from /usr/include/mongo/client/connpool.h:23,
                 from /usr/include/mongo/client/dbclient.h:32,
                 from ninexample.cpp:22:
/usr/include/mongo/bson/bsontypes.h:102:9: note:   ‘BinDataGeneral’
         BinDataGeneral=0,
         ^

我对 C++ 很陌生,所以我不确定为什么这里会出现错误,因为它似乎在 h 文件中看到了 BinDataGeneral 类型。

任何人都可以为我澄清这一点吗?

谢谢!

4

1 回答 1

1

编译器正在寻找BinDataGeneral,但它无法解析该符号。

试试mongo::BinDataGeneral

于 2013-10-17T23:49:37.490 回答