Frage

i'm with a great problem,

i have some code using ZeroMQ and C, and another code that uses MongoDB and C, now i have to merge this codes, but when i try to compile using this command:

gcc -static -lzmq -o logg logger.c /home/lis/mongo-c-driver/libmongoc.a

i got this error stack:

In file included from /usr/local/include/mongo.h:24:0,
                 from write_log.h:13,
                 from get_by_log_code.h:6,
                 from logger.c:23:
/usr/local/include/bson.h:63:2: error: #error Must compile with c99 or define MONGO_HAVE_STDINT, MONGO_HAVE_UNISTD, MONGO_USE__INT64, or MONGO_USE_LONG_INT.
In file included from get_by_log_code.h:6:0,
                 from logger.c:23:
write_log.h: In function ‘write_log’:
write_log.h:70:2: error: incompatible type for argument 1 of ‘mongo_insert’
/usr/local/include/mongo.h:369:18: note: expected ‘struct mongo *’ but argument is of type ‘mongo’
write_log.h:70:2: error: too few arguments to function ‘mongo_insert’
/usr/local/include/mongo.h:369:18: note: declared here

When i installed the Mongo-C-Driver:

i've used make STD=c89, to resolve the conflict between, MongoDB-C-api and ZeroMQ-C-api, in my logger.c file i've defined the variables that error stack asks, but it doesn't works.

War es hilfreich?

Lösung

You should be using --std=c99

c89 is a valid older standard too, which is why you're getting the error.

Andere Tipps

You don't have to use --std=c99

If you're compiling for c++ (or c++11), you can just define this before your include:

#define MONGO_HAVE_STDINT
#include "mongo.h"

That tells the mongo c driver that #include <stdint.h> is present on the system and will properly define int64_t

Alternatively, you can use:

#define MONGO_HAVE_UNISTD
#include "mongo.h"

if you're using #include <unistd.h> instead.

For more details, see https://github.com/mongodb/mongo-c-driver/blob/master/src/bson.h#L52

the error is :

/usr/local/include/bson.h:63:2: error: #error Must compile with c99 or define MONGO_HAVE_STDINT, MONGO_HAVE_UNISTD, MONGO_USE__INT64, or MONGO_USE_LONG_INT.

so comment in header file bson.h from line52 to line 66

something look likes typedef long long int ..

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top