Need replacement for deprecated arrays in error handling
I am modifying an old code, where it uses the deprecated sys_errlist
and sys_nerr
which are deprecated. Can someone tell me its replacement?
Also it will be great, if someone tells us about its functionality.
Here is the code:
37 static const char *
38 stringErrorReport(void)
39 {
40 #if ( defined(sgi) )
41 return strerror(oserror());
42 #elif ( defined(_AIX) )
43 return strerror(errno);
44 #else
45 if ( errno > 0 && errno < sy开发者_如何学Cs_nerr )
46 return sys_errlist[errno];
47 else
48 return "Unknown error.\n";
49 #endif
50 }
Let me know how to replace the deprecated sys_nerr
and sys_errlist[ ]
This function is a wrapper around strerror(), and tries to supply it's own replacement on systems where it assumes strerror() is not available. If even sys_errlist and sys_nerr are not available, it fails. But it has at least tried ...
精彩评论