警告Conversion specifies type'int' but the argument has type'size_t'
代码:

#import<Foundation/Foundation.h>
int main(int argc,const char * argv[]){
const char *words[4]={"mother","father","sister","ms"};
int wordCount=4;
int i;
for(i=0;i<wordCount;i++){
NSLog(@"%s is %d characters long",words[i],strlen(words[i]));
}
return (0);
}

解决:
把%d改为%zu就没有警告了
分析:
%d是输出数字整数,警告里面的size_t是unsigned int
size_t 和int的区别是
size_t是一些C/C++标准在stddef.h中定义的。这个类型足以用来表示对象的大小。
size_t的真实类型与操作系统有关,在32位架构中被普遍定义为:
typedef unsigned int size_t;
而在63位架构中被定义为:
typedef unsigned long size_t;
size_t在32位架构上是4字节,在64位架构上是8字节,在不同架构上进行编译时需要注意这个问题
int在不同架构下都是4字节
int是带符号书,size_t是无符号数
警告Conversion specifies type'int' but the argument has type'size_t'的更多相关文章
- Format specifies type 'int' but the argument has type 'struct node *'
/Users/Rubert/IOS/iworkspace/LineList/LineList/main.c::: Format specifies type 'int' but the argumen ...
- Ubuntu gcc编译报错:format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=]
平时用的都是Centos系统,今天偶然在Ubuntu下编译了一次代码,发现报错了: 源码: #include <stdio.h> #include <sys/time.h> # ...
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGB
Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGB ...
- The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments
The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i ...
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx': no matching editors or conversion strategy found
今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.cor ...
- block中出现此种报错: Incompatible block pointer types initializing 'float (^__strong)(float, float)' with an expression of type 'int (^)(float, float)'
当block(代码块)的返回值是float时,应注意的地方:定义的返回值类型一定要与return的返回值类型一样 我们以两个数的四则运算来举例 在main.m文件中的四则运算中,我采用两种返回值类型( ...
- The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)
The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the ...
- delete attempted to return null from a method with a primitive return type (int)
今天被自己给蠢死了 今天在代码中遇到这个错误, 百度翻译一下:映射方法,从一org.system.mapper.child.chmorganizationexaminationmapper.delet ...
随机推荐
- 爬虫:Scrapy13 - 发送 email
虽然 Python 通过 smtplib 库使得发送 email 变得非常简单,Scrapy 仍然提供了自己的实现.该功能十分易用,同时由于采用了 Twisted 非阻塞式(non-blocking) ...
- SPOJ 149 FSHEEP Fencing in the Sheep ( 计算几何 + 二分 )
以下摘自SPOJ泛做表格: 题意:给定一个星形多边形,而且给出了一个可以看到形内所有点的位置(我们称这个点为观察点),让你判断有多少个点位于多边形内. 时间复杂度:O(mlogn) 将多边形上的点按极 ...
- 八、ISP 接口隔离原则
ISP应用的场景是某些类不符合SRP原则,但使用这些类的客户端应该根据它们的父类来使用(我感觉这句话应该改为:客户端应该根据它们的抽象类\接口来使用它们),而不是直接使用它们. 定义: 客户端不应该依 ...
- C#学习笔记----静态字段和静态方法
1.使用关键字 static 修饰的字段或方法成为静态字段和静态方法,如 public static int num = 1;2.静态字段属于类,并为类所用.而非静态字段属于对象,只能被特定的对象专有 ...
- tomcat调优(Mark)
http://blog.csdn.net/jinwanmeng/article/details/7756591
- Eclipse Tomcat 配置问题
问题描述: Tomcat能启动,ecplise的Console无报错,但是打开http://localhost:8080/报404错误 端口是8080没错,地址也没错,重启了tomcat还是报错,但是 ...
- Java并发(3)- 聊聊Volatile
引言 谈到volatile关键字,大多数开发者都有一定了解,可以说是开发者非常熟悉,深入之后又非常陌生的一个关键字.相当于轻量的synchronized,也叫轻量级锁,与synchronized相比性 ...
- C++封装随笔
1接口的封装和设计思想入门 接口的封装和设计思想入门 第一套api函数 #ifndef _CLT_SOCKET_H__ #define _CLT_SOCKET_H__ //客户端初始化环境 int c ...
- input 输入框提示信息
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 读入输出优化_C++
当我们考试时遇到大量的读入或者输出时,这些代码会耗费许多运行程序的时间,导致TL 本来 log2n 的算法因为读入被卡成线性的就太不划算了,所以我们这里要采用读入输出优化 getchar 和 putc ...