在哪里可以找到为size_t的定义是什么? [英] Where do I find the definition of size_t?

查看:681
本文介绍了在哪里可以找到为size_t的定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这种类型定义的变量,但我不知道它从何而来,也不是什么目的。为什么不使用int或unsigned int? (那其他类似的类型?Void_t,等等)。

I see variables defined with this type but I don't know where it comes from, nor what is its purpose. Why not use int or unsigned int? (What about other "similar" types? Void_t, etc).

推荐答案

维基百科

文件stdlib.h STDDEF.H 头文件定义了一个名为数据类型为size_t 1 的用来重新present一个对象的大小。称取大小库函数期望他们键入为size_t ,而sizeof操作符的计算结果为为size_t

The stdlib.h and stddef.h header files define a datatype called size_t1 which is used to represent the size of an object. Library functions that take sizes expect them to be of type size_t, and the sizeof operator evaluates to size_t.

为size_t 的实际类型是与平台相关的;一个常见的​​错误是假设为size_t 是一样的无符号整数,这可能会导致编程错误,的2 的特别是64位架构变得更为prevalent。

The actual type of size_t is platform-dependent; a common mistake is to assume size_t is the same as unsigned int, which can lead to programming errors,2 particularly as 64-bit architectures become more prevalent.

7.17.1 / 2

以下类型和宏在标准头文件中定义 STDDEF.H

The following types and macros are defined in the standard header stddef.h

<&剪断GT;

<snip>

为size_t

这是sizeof操作符的结果

which is the unsigned integer type of the result of the sizeof operator

这篇关于在哪里可以找到为size_t的定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆