有沒有辦法讓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