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

看板C_and_CPP (C/C++)作者 (好人超)時間14年前 (2011/07/27 01:17), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串2/2 (看更多)
: 很好奇是strerror(errno)可以秀出錯誤訊息的字串 : 但trace一下Linux source code : 都找不到它如何利用strerror找到相對應的字串 要找的不是Linux source code, 而是 GNU C Library http://www.gnu.org/s/libc/libc.html 用 git 把程式碼拉下來 string/strerror.c : strerror 函式最後一行 return __strerror_r (errnum, buf, 1024); string/_strerror.c : __strerror_r 函式最後一行 return (char *) _(_sys_errlist_internal[errnum]); sysdeps/gnu/errlist.c : 裡面是整個 _sys_errlist_internal 陣列的定義 const char *const _sys_errlist_internal[ERRLIST_SIZE] = .... [ERR_REMAP (EAFNOSUPPORT)] = N_("Address family not supported by protocol"), .... }; 看起來就是這樣做的 第一次挖glibc的原始碼,請多多指教XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.35.184.77 ※ 編輯: james732 來自: 114.35.184.77 (07/27 01:18)

07/27 10:50, , 1F
超哥一定要推!
07/27 10:50, 1F

07/27 22:39, , 2F
謝謝 ^__________^
07/27 22:39, 2F

07/28 13:36, , 3F
懷念超哥當家的時候
07/28 13:36, 3F
^^^^^^^^ 這是什麼東西?XD ※ 編輯: james732 來自: 114.35.184.77 (07/28 13:38)

07/28 13:39, , 4F
你當版標的時候
07/28 13:39, 4F

07/28 13:40, , 5F
這種東西不需要懷念啦!! XD
07/28 13:40, 5F

07/28 18:14, , 6F
LOL
07/28 18:14, 6F
文章代碼(AID): #1EBlQzbL (C_and_CPP)
文章代碼(AID): #1EBlQzbL (C_and_CPP)