pointer/integer type mismatch in conditional expre

2019-02-25 03:09发布

gcc 4.7.2 c89

Hello,

I am getting the following warning:

pointer/integer type mismatch in conditional expression

I am compiling with the following CFLAGS -Wall -Wextra

fprintf(stderr, "'Failed to open file' Error [ %s ]\n",
        (errno == 0) ? "None" : strerror(errno));

The program runs ok, but I can't see that the warning is all about. Both "None" and strerror(errno) return a string and not Integer value. And I am comparing errno number to zero.

Many thanks for any suggestions,

1条回答
SAY GOODBYE
2楼-- · 2019-02-25 04:00

Check whether you have included <string.h> header. If not, the return value of strerror may be considered as an integer value. It would explain why the program runs ok (the linker can find a matched function named strerror, because the C standard library is linked by default), whereas the compiler reports a warning.

查看更多
登录 后发表回答