Vik*_*uri 4 c++ gcc typedef g++ mysql++
有没有办法让 g++ 忽略或解决冲突的 typedef?
背景:
我正在为 gridlab_d 模拟器编写一些 C++ 代码。我的模型需要连接到 C++ 数据库,所以我使用的是 mysql++ 库。使用 mysql++ 库需要我链接到 mysql 库,所以我编译
g++ -I/usr/include/mysql -I/usr/local/include/mysql++
问题:
gridlab typedef 中的 mysql.h 和 list.h 都是一个名为 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'
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
也许预处理器包含您问题的解决方案。
#define LIST GRIDLAB_LIST
#include <gridlab_include_file.h>
#undef LIST
Run Code Online (Sandbox Code Playgroud)
当然,这依赖于 gridlab,而不是#include来自 MySQL 的任何东西。