在有条件的前pression指针/整数类型不匹配 [英] pointer/integer type mismatch in conditional expression
问题描述
gcc 4.7.2 c89
您好,
我收到以下警告:
pointer/integer type mismatch in conditional expression
我与编译如下 CFLAGS -Wall -Wextra
fprintf(stderr, "'Failed to open file' Error [ %s ]\n",
(errno == 0) ? "None" : strerror(errno));
该程序运行正常,但我不能看到警告的全部。这两个无和字符串错误(错误)返回一个字符串,而不是整数值。而我的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,
推荐答案
检查您是否已经包括<&string.h中GT;
头。如果不是,字符串错误
的返回值可以被视为一个整数值。这可以解释为什么在程序运行正常(连接器可以找到一个名为匹配功能字符串错误
,因为C标准库是默认链接),而编译器会发出警告。
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.
这篇关于在有条件的前pression指针/整数类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!