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

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

除我添加此行外,它均有效

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。

谁能为我澄清一下?

谢谢!

最佳答案

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

尝试mongo::BinDataGeneral

关于c++ - 功能参数“未在此范围内声明”。参数在h文件中可见,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19439128/

10-11 23:19