Name

wperror,wcserror
- system error messages

Library

libc.lib

Synopsis

  #include <wchar.h>
  void wperror (const wchar_t *string);
  #include <wchar.h>
  wchar_t * wcserror (int errnum);

Return values

The function wcserror returns the appropriate error description wide char string, or an unknown error message if the error code is unknown. The value of errno is not changed for a successful call, and is set to a nonzero value upon error.


Detailed description

The functions wcserror and wperror look up the error message string corresponding to an error number.

The function wcserror function accepts an error number argument errnum (error number) and returns a pointer to the corresponding message string.

The function wperror finds the error message corresponding to the current value of the global variable errno and writes it, followed by a newline, to the standard error file descriptor. If the argument string is non- NULL and does not point to the null character, this wide char string is prepended to the message string and separated from it by a colon and space (": "); otherwise, only the error message string is printed.

If the error number is not recognized, these functions return an error message string containing "Unknown error: " followed by the error number in decimal. The wcserror function returns EINVAL as a warning. Error numbers recognized by this implementation fall in the range 0 < errnum < sys_nerr.

If insufficient storage is provided in strerrbuf (as specified in buflen) to contain the error string, wcserror returns ERANGE and strerrbuf will contain an error message that has been truncated and NUL terminated to fit the length specified by buflen.


Examples

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <wchar.h>
int main()
{
    wchar_t *ptr = wcserror(ERANGE);
    wprintf(L"wcserror(ERANGE) = %s\n",ptr);
    return 0;
}

         

Output

wcserror(ERANGE) = Numerical result out of range

         

See also

perror, strerror,


Bugs

For unknown error numbers, the function wcserror will return its result in a static buffer which may be overwritten by subsequent calls.

The return type for wcserror is missing a type-qualifier. The type-qualifier must be const wchar_t * .


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top