Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
代码
struct sockaddr_in ser; ... #line 68 fprintf(stderr, "Can't find host %s\n", inet_ntoa(ser.sin_addr));
编译(gcc ...)警告
68: warning: format '%s' expects type 'char *', but argument 3 has type 'int'
但是“inet_ntoa()”确实应该返回“char *”,对吧?
默认情况下,在没有活动原型的情况下使用的函数返回一个int. 此行为在 ISO C 标准中指定(至少在 C90 中)。
int
您需要包含声明该函数的头文件,以便编译器具有正确的原型。