[問題] strerror 跟 hstrerror 有何不同
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GNU GCC/G++
問題(Question):
今天看朋友的程式 才知道有 hstrerror 這個函式, 而我朋友傳入 h_errno 給他
不過 man page 寫的讓我很困惑,
The (obsolete) hstrerror() function takes an error number (typically h_errno)
and returns the corresponding message string.
這邊的 obsolete 到底是指什麼呢?
http://ftp.suacommunity.com/man/3/strerror.3.html
然後這裡寫的更讓我困惑@@
The hstrerror(3) call is a #define for strerror(3), provided for
convenience in working with sockets.
所以這兩個根本沒有差嗎?
可是好像 h_errno, errno 是不同變數, hstrerror 跟 strerror 也是不同函數.
所以這兩個函數有差嗎? 印 socket 相關的錯誤訊息 (如 gethostbyname 錯誤)
應該使用 hstrerror 嗎?
man page 裡面又寫
RETURN VALUE
The gethostbyname() and gethostbyaddr() functions return the hos-
tent structure or a NULL pointer if an error occurs. On error,
the h_errno variable holds an error number. When non-NULL, the
return value may point at static data, see the notes below.
所以我使用 errno 就夠了?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.166.45.226
→
12/01 14:03, , 1F
12/01 14:03, 1F
→
12/01 14:06, , 2F
12/01 14:06, 2F
→
12/01 14:06, , 3F
12/01 14:06, 3F
→
12/01 14:07, , 4F
12/01 14:07, 4F
→
12/01 14:08, , 5F
12/01 14:08, 5F
→
12/01 14:09, , 6F
12/01 14:09, 6F
→
12/01 14:10, , 7F
12/01 14:10, 7F
→
12/01 14:10, , 8F
12/01 14:10, 8F
→
12/01 14:12, , 9F
12/01 14:12, 9F
→
12/01 14:12, , 10F
12/01 14:12, 10F
→
12/01 18:31, , 11F
12/01 18:31, 11F
→
12/01 18:42, , 12F
12/01 18:42, 12F
→
12/01 18:42, , 13F
12/01 18:42, 13F
→
12/02 09:53, , 14F
12/02 09:53, 14F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章