Zombo
Zombo

Reputation: 1

strerror with MinGW-w64

Take this simple program

#include <stdio.h>
#include <string.h>
#include <errno.h>

int
main (void)
{
  printf ("ERROR %d %s\n", ETIMEDOUT, strerror (ETIMEDOUT));
  return 0;
}

If you compile it with Cygwin gcc it runs fine

$ gcc a.c

$ ./a
ERROR 116 Connection timed out

If you compile it with MinGW-w64 gcc it does not give proper error message

$ i686-w64-mingw32-gcc a.c

$ ./a
ERROR 138 Unknown error

How can I get MinGW-w64 to put correct error message?

Upvotes: 6

Views: 1421

Answers (1)

David L.
David L.

Reputation: 2103

ETIMEDOUT seems to be a POSIX extension to the ISO C standard errno.h. Cygwin has better support for POSIX than MinGW. A bug report about ETIMEDOUT for mingw32 was opened and closed in 2007.

One option is to use the GNU Portability Library (Gnulib). It provides a POSIX-like errno.h and strerror()/strerror_override() .

Upvotes: 2

Related Questions