看板 LinuxDev 關於我們 聯絡資訊
※ [本文轉錄自 C_and_CPP 看板 #1PpwzCAE ] 作者: gowrite (gowrite) 看板: C_and_CPP 標題: [問題] 有關於 header 在 linux 的幾個問題 時間: Sat Sep 30 22:50:49 2017 開發平台(Platform): (Ex: Win10, Linux, ...) linux 4.10.0-28 ubuntu 16.4 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gnu gcc 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) n/a 問題(Question): 新手自學 在 linux 環境下寫 C,有一個小問題就是關於 include header 雖然在 C 程式裡面只要 #include <xxxxxxx.h> 這樣就可以了 但是有些書上的範例程式會用到沒看過的 header 檔 想把 header 檔打開來看一下內容是甚麼 但是去 linux 的 /usr/include 下面看,又有好幾個同名,但是在不同目錄的標頭檔 請問這個時候如果想要 trace code 的話要怎麼做, 怎麼知道在 C 語言是 include 哪個檔案?? 餵入的資料(Input): 例如: 假設我在我的程式裡面 #include <stddef.h> 但我在 bash 裡面搜尋有關 stddef.h find /usr/include -name stddef.h 會找到好幾個 stddef.h 如圖: https://imgur.com/a/NJgZ0 雖然把檔案一個一個打開來看 code 最後應該還是可以猜得出來, 但還是想問一下有沒有比較快且正確的方法?? 例如: 有沒有方法可以知道 compiler 在 compile & link 的時候, link header 所參照的路徑呢? 或是其他方法嗎? 謝謝 預期的正確結果(Expected Output): n/a 錯誤結果(Wrong Output): n/a 程式碼(Code):(請善用置底文網頁, 記得排版) n/a 補充說明(Supplement): n/a -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.137.75.238 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1506783052.A.28E.html ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: gowrite (114.137.75.238), 09/30/2017 22:52:01
kingofsdtw: g++ -v 10/01 08:30
kingofsdtw: --with-gxx-include-dir=/usr/include/c++/ 10/01 08:33
kingofsdtw: C : /usr/include or /usr/local/include/ 10/01 08:41
kingofsdtw: how to ignore std inlcude path ? 10/01 08:46
kingofsdtw: https://goo.gl/w3cWDp 10/01 08:46
kingofsdtw: ex. ./kernel/linux/Makefile: 10/01 09:35
kingofsdtw: NOSTDINC_FLAGS += -nostdinc 10/01 09:35