以这个简单的程序为例
#include <stdio.h>
#include <string.h>
#include <errno.h>
int
main (void)
{
printf ("ERROR %d %s\n", ETIMEDOUT, strerror (ETIMEDOUT));
return 0;
}如果你用Cygwin编译,那么它运行的很好
$ gcc a.c
$ ./a
ERROR 116 Connection timed out如果您使用MinGW-w64编译,则不会给出正确的错误消息
$ i686-w64-mingw32-gcc a.c
$ ./a
ERROR 138 Unknown error如何让MinGW-w64放入正确的错误信息?
发布于 2012-11-23 14:30:38
ETIMEDOUT似乎是ISO标准errno.h的POSIX扩展。Cygwin对POSIX的支持比MinGW更好。在2007中打开和关闭了有关mingw32的ETIMEDOUT的错误报告。
一种选择是使用GNU Portability (Gnulib)。它提供了一个类似POSIX的errno.h和strerror()/strerror_override()。
https://stackoverflow.com/questions/13523532
复制相似问题