我正在尝试构建 mongo-cxx-driver 库
mmuratet@fisher:~/mongo-cxx-driver/build$ cmake --prefix=/usr/local ..
-- No build type selected, default is Release
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mmuratet/mongo-cxx-driver/build
mmuratet@fisher:~/mongo-cxx-driver/build$ make
[ 3%] Built target EP_mnmlstc_core
[ 10%] Built target bsoncxx
[ 16%] Built target bsoncxx_static
[ 21%] Built target test_bson
[ 22%] Building CXX object src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o
In file included from /usr/local/include/libbson-1.0/bson-compat.h:38:0,
from /usr/local/include/libbson-1.0/bson.h:23,
from /home/mmuratet/mongo-cxx-driver/src/mongocxx/private/libbson.hpp:17,
from /home/mmuratet/mongo-cxx-driver/src/mongocxx/bulk_write.cpp:18:
/usr/local/include/libbson-1.0/bson-macros.h:48:28: error: expected declaration before ‘}’ token
# define BSON_END_DECLS }
^
/usr/local/include/libmongoc-1.0/mongoc-stream-tls-private.h:61:1: note: in expansion of macro ‘BSON_END_DECLS’
BSON_END_DECLS
^ make[2]: * [src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o] 错误 1 make[1]: * [src/mongocxx/CMakeFiles/mongocxx.dir/all] 错误2 make: *** [all] 错误 2
得到上面的错误。
这是有问题的代码(由 less 添加的 #s 行):
46 #ifdef __cplusplus
47 # define BSON_BEGIN_DECLS extern "C" {
48 # define BSON_END_DECLS }
49 #else
50 # define BSON_BEGIN_DECLS
51 # define BSON_END_DECLS
52 #endif
我觉得这段代码没问题。有人可以指出我错过了什么吗?包含的上游会不会有问题?如何找到它?
干杯
最佳答案
看来您正在使用 master 分支中的 libmongoc,它似乎有一个错误,即 BSON_END_DECLS 没有与上面的 BEGIN_DECLS 配对(它在之前的提交中被意外删除)
我已经在以下位置提交了错误:https://jira.mongodb.org/browse/CDRIVER-1162
1.3.4 标签是一个实际的稳定版本,似乎没有同样的问题。
关于c++ define指令失败,代码看起来不错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35348231/