Linux C 編程一站式學習
#pragma 預處理指示供編譯器實現一些非標準的特性,C 標準沒有規定 #pragma 后面應該寫什么以及起什么作用,由編譯器自己規定。有的編譯器用 #pragma 定義一些特殊功能寄存器名,有的編譯器用 #pragma 定位鏈接地址,本書不做深入討論。如果編譯器在代碼中碰到不認識的 #pragma 指示則忽略它,例如 gcc 的 #pragma 指示都是 #pragma GCC ?...這種形式,用別的編譯器編譯則忽略這些指示。
?
VC 可以用 #pragma comment 來指示鏈接的靜態庫,這個就比較神奇了,一般指定鏈接的靜態庫都是通過鏈接器的參數去指定,而這個卻將它放到了代碼中,例如:
#pragma comment( lib, "emapi" )
The following pragma causes the linker to search for the EMAPI.LIB library while linking. The linker searches first in the current working directory and then in the path specified in the LIB environment variable.