我有一個庫(ws2_32)和一個頭文件(ws2tcpip.h),但由於某種原因庫中的函數不在頭文件中。有沒有一種方法可以確定方法簽名,以便我可以將它們包含在頭文件中?我可以從靜態庫中創建標題嗎?
[email protected] ~$ strings /usr/lib/w32api/libws2_32.a | grep -i 'inet_*ntop'
[email protected]
[email protected]
[email protected]
[email protected]
inet_ntop <<< I need this one
[email protected]
[email protected]
InetNtopW <<< or this one
[email protected]
[email protected]
[email protected] ~$ grep -i -B 4 -A 2 -R "ntop" /usr/include/w32api/ws2tcpip.h
[email protected] ~$
這應該是可能的,因爲鏈接器必須驗證這一點,不是嗎?
參考:InetNtop and ws2tcpip.h under GCC/Cygwin
對於C函數,鏈接器通常只檢查函數名稱是否匹配,而不是它們具有相同類型或調用約定。在某些系統中,連接器甚至不會驗證你所調用的函數是一個函數,它可能是一大塊數據。 –