【发布时间】:2012-01-14 22:09:37
【问题描述】:
有没有办法让 g++ 忽略或解决冲突的 typedef?
背景:
我正在为 gridlab_d 模拟器编写一些 C++ 代码。我的模型需要连接到 C++ 数据库,所以我使用的是 mysql++ 库。使用 mysql++ 库需要我链接到 mysql 库,所以我用
编译g++ -I/usr/include/mysql -I/usr/local/include/mysql++
问题:
gridlab 中的 mysql.h 和 list.h 都将 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放在其中一个定义周围吗? -
也许你可以创建自己的可以独立编译的抽象,这样两个 typedef 就不会出现在同一个编译单元中。
标签: c++ gcc g++ typedef mysql++