Compiling C code with conflicting types


I'm coding a program that uses ossp-uuid which defines a type called uuid_t. Now, the problem that I have is that this type is already defined in Mac OSX in the file unistd.h.

So, the error I get is:

/opt/local/include/ossp/uuid.h:94: error: conflicting types for 'uuid_t'
/usr/include/unistd.h:133: error: previous declaration of 'uuid_t' was here

I complile my program with:

-DPACKAGE=\"epride\" -DVERSION=\"0.2\" -I.    -I/usr/local/BerkeleyDB.4.7/include 
-I/opt/local/include -I/opt/local/include/db47 -I/opt/local/include/libxml2 
`pkg-config --cflags glib-2.0` -DNUM_REPLICAS=1 -DGEN_SIZE=10 -g -O2 -MT 
libepride_a-conflictset.o -MD -MP -MF .deps/libepride_a-conflictset.Tpo
-c -o libepride_a-conflictset.o `test -f 'conflictset.c' 
|| echo './'`conflictset.c

Is there a way to tell gcc that he should ignore the type from unistd.h? Because I'm using unistd.h for other things.

In uuid.h there is these lines:

/* workaround conflicts with system headers */
#define uuid_t       __vendor_uuid_t
#define uuid_create  __vendor_uuid_create
#define uuid_compare __vendor_uuid_compare
#include <sys/types.h>
#include <unistd.h>
#undef  uuid_t
#undef  uuid_create
#undef  uuid_compare

Shouldn't that take care of it?

Thanks in advance!

Best Solution

You should check /opt/local/include/ossp/uuid.h at line 94 and hope that there's a define for uuid_t. Hopefully you'll find something like:

typedef uuid_t .... whatever

If the guys who wrote that header did it in this way, then you can modify your code:

#include <unistd.h>
#include <ossp/uuid.h>

This way, he second #include won't hit the declaration of uuid_t in ossp/uuid.h.