我正在编写一个使用ossp-uuid的程序,它定义了一个名为uuid_t的类型。现在,我遇到的问题是这种类型已经在Mac OSX中的unistd.h文件中定义了。编译具有冲突类型的C代码
所以,我得到的错误是:
/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
我请编译我的程序有:
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -
DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\"
-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
有没有办法告诉GCC,他应该忽略来自unistd.h中的类型?因为我使用unistd.h来处理其他事情。
在uuid.h有这些行:
/* 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
难道不应该照顾它?
在此先感谢!
解决的办法是添加此,我使用uuid_t: 的#ifndef _UUID_T 的#include #ENDIF –
DeeD