[討論] <errno> strerror()找不到errno定義的字串

看板C_and_CPP (C/C++)作者 (就是愛希爾)時間14年前 (2011/07/27 00:34), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/2 (看更多)
目前在執行某支應用程式時 出現socket: Address family not supported by protocol 的錯誤訊息 就想說看一下errno部分 而在Linux source code找Address family not supported by protocol 的關鍵字(#grep -irn "Address family not supported by protocol" * --color) 只在./kernel/arch/mips/include/asm/errno.h 看到有定義 #define EAFNOSUPPORT 124 /* Address family not supported by protocol */ 此外就找不到相關的關鍵字 很好奇是strerror(errno)可以秀出錯誤訊息的字串 但trace一下Linux source code 都找不到它如何利用strerror找到相對應的字串 只在 ./kernel/arch/um/include/shared/kern.h 裡面定義 extern void perror(char *err); extern void strerror(char *err); 那它是如何利用errno來找到相對應的字串呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.219.143

07/27 00:45, , 1F
我猜它不是在kernel裡,而是在c library裡
07/27 00:45, 1F

07/27 01:01, , 2F
Errors: errno in UNIX programs - Chris Herborth
07/27 01:01, 2F

07/27 01:04, , 3F
07/27 01:04, 3F
文章代碼(AID): #1EBkoQ5S (C_and_CPP)
文章代碼(AID): #1EBkoQ5S (C_and_CPP)