有没有办法让g ++忽略或解决冲突的typedefs?在typedef C++中避免冲突的声明错误
背景:
我写了gridlab_d模拟器一些C++代码。我的模型需要连接到一个C++数据库,所以我使用的是mysql ++库。使用MySQL ++的图书馆需要我链接到MySQL库,所以我编译
g++ -I/usr/include/mysql -I/usr/local/include/mysql++
问题:
的mysql.h都和list.h在gridlab的typedef一个结构有名字LIST。这是编译器错误
In file included from /usr/include/mysql/mysql.h:76,
from /usr/include/mysql++/common.h:182,
from /usr/include/mysql++/connection.h:38,
from /usr/include/mysql++/mysql++.h:56,
from direct_data.cpp:21:
/usr/include/mysql/my_list.h: At global scope:
/usr/include/mysql/my_list.h:26: error: conflicting declaration 'typedef struct st_list LIST'
../core/list.h:22: error: 'LIST' has a previous declaration as 'typedef struct s_list LIST'
感谢您的帮助!
你不能把'#ifndef'围绕其中一个定义? – lapk 2012-01-14 22:13:34
也许你可以创建自己的可以独立编译的抽象,所以这两个typedef不会出现在同一个编译单元中。 – 2012-01-14 22:16:31