And*_*nle 14
ssize_t中定义sys/types.h。
根据POSIX 文档:
姓名
sys/types.h - 数据类型
概要
Run Code Online (Sandbox Code Playgroud)#include <sys/types.h>描述
标题至少应定义以下类型:
...
ssize_t用于字节计数或错误指示。
从版本 5.9 开始,Linux 手册页记录了系统数据类型,以便您可以轻松地集中找到这些信息。
\n只需输入man ssize_t:
ssize_t(3type) Linux Programmer\xe2\x80\x99s Manual ssize_t(3type)\n\nNAME\n ssize_t - count of bytes or an error indication\n\nLIBRARY\n Standard C library (libc)\n\nSYNOPSIS\n #include <sys/types.h>\n\n typedef /* ... */ ssize_t;\n\nDESCRIPTION\n Used for a count of bytes or an error indication. Ac\xe2\x80\x90\n cording to POSIX, it shall be a signed integer type capa\xe2\x80\x90\n ble of storing values at least in the range [-1,\n SSIZE_MAX], and the implementation shall support one or\n more programming environments where the width of ssize_t\n is no greater than the width of the type long.\n\n Glibc and most other implementations provide a length\n modifier for ssize_t for the printf(3) and the scanf(3)\n families of functions, which is z; resulting commonly in\n %zd or %zi for printing ssize_t values. Although z works\n for ssize_t on most implementations, portable POSIX pro\xe2\x80\x90\n grams should avoid using it\xe2\x80\x94for example, by converting\n the value to intmax_t and using its length modifier (j).\n\nVERSIONS\n <aio.h>, <mqueue.h>, and <sys/socket.h> define ssize_t\n since POSIX.1\xe2\x80\x902008.\n\nCONFORMING TO\n POSIX.1\xe2\x80\x902001 and later.\n\nNOTES\n The following headers also provide this type: <aio.h>,\n <monetary.h>, <mqueue.h>, <stdio.h>, <sys/msg.h>,\n <sys/socket.h>, <sys/uio.h>, and <unistd.h>.\n\nSEE ALSO\n read(2), readlink(2), readv(2), recv(2), send(2),\n write(2), ptrdiff_t(3type), size_t(3type)\n\nLinux 2022\xe2\x80\x9006\xe2\x80\x9017 ssize_t(3type)\nRun Code Online (Sandbox Code Playgroud)\n如果您只是想要ssize_t,您应该包含它<sys/types.h>,这是它的规范标头,并且可能是提供的最轻的标头ssize_t。但是,它是由记录的任何标头提供的,因此如果您碰巧还需要在其他标头之一中定义,则可以仅包含该其他标头。