warning: format ‘%s’ expects argument of type ‘char *’和warning: backslash and newline separated by
来源:互联网 发布:logo在线制作软件 编辑:程序博客网 时间:2024/05/16 06:35
关于程序中产生的警告:
1,
echoserv.c:49:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=] printf("ip = %s\n", inet_ntoa(peeraddr.sin_addr)); ^2,
echoserv.c:11:24: warning: backslash and newline separated by space [enabled by default] exit(EXIT_FAILURE); \ ^
编写socket程序的过程中用到了这个函数:
char *inet_ntoa(struct in_addr inaddr);
返回:指向一个点分十进制数串的指针
不过,我写到程序中,却是产生了一个警告,(个人不太喜欢警告)
printf("ip = %s \n", inet_ntoa(peeraddr.sin_addr));
警告:
、
产生的这个错误简直都不能理解,明明这个函数的返回值是char *,刚好用%s来进行输出,但是编译器却给出了返回值为int的说法,实在理解不了,,,
后来,仔细的调试程序,发现程序的头文件并没有,当我将程序的头文件加上之后,就没有了这个警告
也就是说:这个函数在没有头文件的情况下,返回值确实为int,有头文件时,返回值为char *
2,在我用#define-do-while的时候
出现了这样的问题
程序如上,但是经过编译器的编译,程序同样性的产生了一个警告!!!
一开始,看到了错误然后没有太管,直接百度,耗费了好一阵时间,也没有找到直接性的解决办法,,,
最后,仔细看了看错误的原因,发现大概说的是:多了一个空格
如上,是去掉空格后的情况!!!,可以发现颜色都有不同的变化,,,哈哈,这回也明白了英语的重要性!!!
warning: assignment makes pointer from integer without a cast [enabled by default]
这种错误一般是:忘了加头文件
如:我使用gethostbyname函数的时候,忘了加头文件了,,,
其中:头文件为(Linux):#include<netdb.h>
0 0
- warning: format ‘%s’ expects argument of type ‘char *’和warning: backslash and newline separated by
- warning: backslash and newline separated by space
- warning: backslash and newline separated by space
- inet_ntoa warning: format '%s' expects type 'char *', but argument 2 has type 'int'
- 写宏遇到的问题:warning: backslash and newline separated by space - C
- 写宏遇到的问题:warning: backslash and newline separated by space - C
- 写宏遇到的问题:warning: backslash and newline separated by space - C
- 写宏遇到的问题:warning: backslash and newline separated by space
- 写宏遇到的问题:warning: backslash and newline separated by space - C
- [C/C++]warning: format '%c' expects argument of type 'char*', but argument 2 has type 'int' [-Wforma
- jni编译时出现:warning: format '%d' expects argument of type 'int', but argument 4 has
- 编译告警:“warning: format '%d' expects type 'int', but argument 4 has type 'unsigned long'”
- inet_ntoa编译提示警告: 格式 ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
- g++编译报错原因分析 format ?.d?.expects argument of type ?.nt?. but argument 3 has type ?.
- linux c之提示format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat
- warning: passing argument 2 of 'request_irq' from incompatible pointer type导致的中断申请失败和
- warning: passing argument 2 of 'request_irq' from incompatible pointer type导致的中断申请失败和
- warning: no newline at end of file
- sax方法进行xml解析
- 方法的重载
- js跨域问题浅析及解决方法优缺点对比
- 地理配准工具条为灰色的原因
- 快速多人游戏(2) - 客户端预测和服务器校验
- warning: format ‘%s’ expects argument of type ‘char *’和warning: backslash and newline separated by
- 学习SpringMVC(二十四)之异常处理
- 如何让服务器支持跨域
- service
- linux下安装jdk及配置环境变量
- 204. Count Primes
- iOS的主要框架介绍
- NGUI中sprite出现透明边框(黑线)
- HDR全局色调映射算法实现