Fw: [問題] 有關於 header 在 linux 的幾個問題

作者: gowrite (gowrite)   2017-09-30 22:52:01
※ [本文轉錄自 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
作者: kingofsdtw (不能閒下來!!)   2017-10-01 08:30:00
g++ -v--with-gxx-include-dir=/usr/include/c++/C : /usr/include or /usr/local/include/how to ignore std inlcude path ?https://goo.gl/w3cWDpex. ./kernel/linux/Makefile:NOSTDINC_FLAGS += -nostdinc

Links booklink

Contact Us: admin [ a t ] ucptt.com