[問題] c語言 重複定義編譯錯誤

看板C_and_CPP (C/C++)作者 (komo)時間2小時前 (2026/03/28 01:30), 2小時前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) Win10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)GCC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 想請教一個專案遇到編譯錯誤的問題: 有三個文件 a.h 定義一個結構 typedef struct person 定義一個巨集 define macro1 b.h 定義一個結構 typedef struct person 定義一個巨集 define macro2 main.c 必須用到macro1和macro2 所以include a.h和b.h 這時候編譯會遇到struct redefinition error 但是a.h和b.h都是別人寫好的,內容不能改 想請問這樣要怎麼解決?謝謝 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) 補充說明(Supplement): ---- Sent from BePTT on my Samsung SM-S9480 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.228.124.9 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1774632623.A.3AB.html ※ 編輯: komododo (36.228.124.9 臺灣), 03/28/2026 01:33:10
文章代碼(AID): #1fnhwlEh (C_and_CPP)
文章代碼(AID): #1fnhwlEh (C_and_CPP)