C Linux中ssize_t的定义在哪里?
操作系统:Debian9(Linux 4.9) 编译器:GCC 8.2 目前,我包括C Linux中ssize_t的定义在哪里?,c,linux,types,include,posix,C,Linux,Types,Include,Posix,操作系统:Debian9(Linux 4.9) 编译器:GCC 8.2 目前,我包括(其中定义了大小)和(其中定义了大多数整数类型),但我仍然没有ssize\t 它在哪里定义?ssize\u t在sys/types.h中定义 Per: 名称 sys/types.h-数据类型 简介 #include <sys/types.h> #包括 说明 标题应至少定义以下类型: ssize\u t 用于字节计数或错误指示 自版本5.9以来,Linux手册页记录了系统数据类型,因此您可以以集中
(其中定义了大小)和
(其中定义了大多数整数类型),但我仍然没有ssize\t
它在哪里定义?ssize\u t
在sys/types.h
中定义
Per:
名称
sys/types.h-数据类型
简介
#include <sys/types.h>
#包括
说明
标题应至少定义以下类型:
ssize\u t
用于字节计数或错误指示
自版本5.9以来,Linux手册页记录了系统数据类型,因此您可以以集中的方式轻松找到这些信息
仅键入:
如果您只想ssize\u t
,那么应该包括
,这是它的规范头,可能是提供ssize\u t
的最轻头。但是,它是由任何记录的标题提供的,因此,如果您碰巧还需要这些其他标题中的某个标题的定义,则可以仅包括该其他标题。#include#include
或#include
Posix+1,用于询问以前似乎没有提出过的基本问题。或者我无法使用两个搜索引擎找到它。请注意,即使您包括
,如果您使用GCC(-std=c99
)而不是GNU变量(-std=gnu99
)指定了严格的C标准,则可能无法定义类型。然后,您需要启用POSIX扩展,可能是使用#define(定义)XOPEN(源代码700)
(这个数字比#define(定义)POSIX(源代码200809L)更容易记住
)这是一个有效的替代方案;X/Open和POSIX之间有细微的区别,但它们很小,也很少相关。在包含任何系统标题之前,必须显示#define
。它可以在命令行中指定为-D\u XOPEN\u SOURCE=700
。我使用的是Ubuntu 20.04man-ssize\u t
只为我显示了以下内容:没有手动输入ssize\u t
@GabrielStaples Ubuntu 20.04有man-pages-5.05
。你可以通过阅读手册简介
(或者手册页
项目提供的任何手册页(Ubuntu上的手册页都在手册页
和手册页开发
包中)的冒号轻松检查你的版本。在查找了什么意思后,因为这个词对我的词汇来说太大了,我搜索了man intro
页面,在最下面看到了我的版本。多谢各位COLOPHON此页面是Linux手册页项目5.05版的一部分。
。Ubuntu 20.04的手册页版本为5.05。如果您对升级手册页感兴趣(这是一个非常安全和可逆的操作),那么从源代码:git clone进行升级很简单git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git &&cd手册页和制作安装
。您可以进行卸载
以恢复安装并恢复正常(您的系统手册页面不会被覆盖,因为它使用
进行安装)。只需按照自述。
ssize_t
Include: <sys/types.h>. Alternatively, <aio.h>, <monetary.h>,
<mqueue.h>, <stdio.h>, <sys/msg.h>, <sys/socket.h>, <sys/uio.h>,
or <unistd.h>.
Used for a count of bytes or an error indication. According to
POSIX, it shall be a signed integer type capable of storing val-
ues at least in the range [-1, SSIZE_MAX], and the implementa-
tion shall support one or more programming environments where
the width of ssize_t is no greater than the width of the type
long.
Glibc and most other implementations provide a length modifier
for ssize_t for the printf(3) and the scanf(3) families of func-
tions, which is z; resulting commonly in %zd or %zi for printing
ssize_t values. Although z works for ssize_t on most implemen-
tations, portable POSIX programs should avoid using it--for ex-
ample, by converting the value to intmax_t and using its length
modifier (j).
Conforming to: POSIX.1-2001 and later.
See also: read(2), readlink(2), readv(2), recv(2), send(2),
write(2)
See also the ptrdiff_t and size_t types in this page.
NOTES
[...]
Conventions used in this page
[...]
In "Include", we first note the "primary" header(s) that define the
type according to either the C or POSIX.1 standards. Under "Alterna-
tively", we note additional headers that the standards specify shall
define the type.