SYSTEM_DATA_TYPES(7)
๐ NAME ๐
system_data_types โ an overview of system data types. that's the whole assignment bestie, no cap. ๐ธ
This is the Linux Programmer's Manual page SYSTEM_DATA_TYPES(7), and it's a long one so we're doing it in three parts โ this is part one, so buckle up. ๐ซถ
๐ DESCRIPTION ๐
okay so listen. the system hands you a whole squad of data types โ integers, structs, floating thingies โ and this page is the master list so you know exactly what each one is, where it lives, and who's supposed to define it. let's go type by type, alphabetically, iconic behavior. โจ
๐ฆ aiocb
Include: <aio.h>.
struct aiocb {
int aio_fildes; /* File descriptor */
off_t aio_offset; /* File offset */
volatile void *aio_buf; /* Location of buffer */
size_t aio_nbytes; /* Length of transfer */
int aio_reqprio; /* Request priority offset */
struct sigevent aio_sigevent; /* Signal number and value */
int aio_lio_opcode;/* Operation to be performed */
};
want the whole deep-dive tea on this struct? go read aio(7), it's all there. ๐
Conforming to: POSIX.1-2001 and later.
See also: aio_cancel(3), aio_error(3), aio_fsync(3), aio_read(3), aio_return(3), aio_suspend(3), aio_write(3), lio_listio(3)
โฐ clock_t
Include: <time.h> or <sys/types.h>. Alternatively, <sys/time.h>.
it's for system time in clock ticks, or in CLOCKS_PER_SEC (which is defined in <time.h>, fyi). per POSIX it shall be an integer type or a real-floating type. yes, "real-floating" is a whole phrase, it's giving academic. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
๐ฐ๏ธ clockid_t
Include: <sys/types.h>. Alternatively, <time.h>.
this is the clock ID type used in the clock and timer functions. per POSIX it shall be defined as an arithmetic type. simple. clean. efficient. ๐
Conforming to: POSIX.1-2001 and later.
See also: clock_adjtime(2), clock_getres(2), clock_nanosleep(2), timer_create(2), clock_getcpuclockid(3)
๐ dev_t
Include: <sys/types.h>. Alternatively, <sys/stat.h>.
device IDs live here. per POSIX it shall be an integer type. for the full lore on this type, makedev(3) has you covered. ๐
Conforming to: POSIX.1-2001 and later.
โ div_t
Include: <stdlib.h>.
typedef struct {
int quot; /* Quotient */
int rem; /* Remainder */
} div_t;
it's literally just the type of the value that the div(3) function hands back. quotient, remainder, done. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: div(3)
๐ง double_t
Include: <math.h>.
the implementation's most efficient floating type that's at least as wide as double. its actual type depends on the value of the macro FLT_EVAL_METHOD (defined in <float.h>, bestie):
0โdouble_tisdouble.1โdouble_tisdouble.2โdouble_tislong double.
for any other values of FLT_EVAL_METHOD, the type of double_t is implementation-defined. so like, your mileage may vary, no promises. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: the float_t type in this page.
๐๏ธ fd_set
Include: <sys/select.h>. Alternatively, <sys/time.h>.
a structure type that can represent a whole set of file descriptors. per POSIX, the maximum number of file descriptors you can cram into an fd_set structure is the value of the macro FD_SETSIZE. don't overflow it, queen. โ ๏ธ
Conforming to: POSIX.1-2001 and later.
See also: select(2)
๐ fenv_t
Include: <fenv.h>.
this type represents the entire floating-point environment โ control modes, status flags, all of it. for further details, go see fenv(3). it's the whole package. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: fenv(3)
๐ฉ fexcept_t
Include: <fenv.h>.
this one represents the floating-point status flags collectively. for further details see fenv(3). it's the flags only, not the whole environment โ know the difference bestie. โจ
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: fenv(3)
๐ FILE
Include: <stdio.h>. Alternatively, <wchar.h>.
an object type used for streams. yes, THE FILE. the main character of every I/O function you've ever written. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: fclose(3), flockfile(3), fopen(3), fprintf(3), fread(3), fscanf(3), stdin(3), stdio(3)
๐ซง float_t
Include: <math.h>.
the implementation's most efficient floating type that's at least as wide as float. its type depends on the value of the macro FLT_EVAL_METHOD (defined in <float.h>):
0โfloat_tisfloat.1โfloat_tisdouble.2โfloat_tislong double.
for other values of FLT_EVAL_METHOD, the type of float_t is implementation-defined. ๐
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: the double_t type in this page.
๐ฅ gid_t
Include: <sys/types.h>. Alternatively, <grp.h>, <pwd.h>, <signal.h>, <stropts.h>, <sys/ipc.h>, <sys/stat.h>, or <unistd.h>.
a type used to hold group IDs. per POSIX, this shall be an integer type. look at that alternate-include list, it's giving popular. ๐
Conforming to: POSIX.1-2001 and later.
See also: chown(2), getgid(2), getegid(2), getgroups(2), getresgid(2), getgrnam(2), credentials(7)
๐ id_t
Include: <sys/types.h>. Alternatively, <sys/resource.h>.
a type used to hold a general identifier. per POSIX, this shall be an integer type that can be used to contain a pid_t, uid_t, or gid_t. it's the flexible friend of the ID world. ๐
Conforming to: POSIX.1-2001 and later.
See also: getpriority(2), waitid(2)
๐งฎ imaxdiv_t
Include: <inttypes.h>.
typedef struct {
intmax_t quot; /* Quotient */
intmax_t rem; /* Remainder */
} imaxdiv_t;
it is the type of the value returned by the imaxdiv(3) function. quotient + remainder, but make it intmax_t. โญ
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: imaxdiv(3)
๐ข intmax_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
a signed integer type capable of representing any value of any signed integer type supported by the implementation. per the C language standard, it shall be capable of storing values in the range [INTMAX_MIN, INTMAX_MAX]. it's the biggest signed int in the room and it knows it. ๐
the macro INTMAX_C() expands its argument to an integer constant of type intmax_t.
the length modifier for intmax_t for the printf(3) and the scanf(3) families of functions is j; resulting commonly in %jd or %ji for printing intmax_t values.
Conforming to: C99 and later; POSIX.1-2001 and later.
Bugs:intmax_tis not large enough to represent values of type__int128in implementations where__int128is defined andlong longis less than 128 bits wide. ๐ yeah, that's a real limitation, not a vibe.
See also: the uintmax_t type in this page.
๐ intN_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
int8_t, int16_t, int32_t, int64_t
a signed integer type of a fixed width of exactly N bits, where N is the value specified in its type name. per the C language standard, they shall be capable of storing values in the range [INTN_MIN, INTN_MAX], substituting N by the appropriate number. fixed width, no surprises, we love that. โจ
per POSIX, int8_t, int16_t, and int32_t are required; int64_t is only required in implementations that provide integer types with width 64; and all other types of this form are optional. so like, int64_t is the popular one but technically not guaranteed everywhere. ๐ซ
the length modifiers for the intN_t types for the printf(3) family of functions are expanded by macros of the forms PRIdN and PRIiN (defined in <inttypes.h>); resulting for example in %"PRId64" or %"PRIi64" for printing int64_t values. the length modifiers for the intN_t types for the scanf(3) family of functions are expanded by macros of the forms SCNdN and SCNiN, (defined in <inttypes.h>); resulting for example in %"SCNd8" or %"SCNi8" for scanning int8_t values.
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: the intmax_t, uintN_t, and uintmax_t types in this page.
๐ intptr_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
a signed integer type such that any valid (void *) value can be converted to this type and back. per the C language standard, it shall be capable of storing values in the range [INTPTR_MIN, INTPTR_MAX]. pointers in, integers out, integers in, pointers out. round trip slay. ๐
the length modifier for intptr_t for the printf(3) family of functions is expanded by the macros PRIdPTR and PRIiPTR (defined in <inttypes.h>); resulting commonly in %"PRIdPTR" or %"PRIiPTR" for printing intptr_t values. the length modifier for intptr_t for the scanf(3) family of functions is expanded by the macros SCNdPTR and SCNiPTR, (defined in <inttypes.h>); resulting commonly in %"SCNdPTR" or %"SCNiPTR" for scanning intptr_t values.
Conforming to: C99 and later; POSIX.1-2001 and later.
See also: the uintptr_t and void * types in this page.
๐ฐ lconv
Include: <locale.h>.
struct lconv { /* Values in the "C" locale: */
char *decimal_point; /* "." */
char *thousands_sep; /* "" */
char *grouping; /* "" */
char *mon_decimal_point; /* "" */
char *mon_thousands_sep; /* "" */
char *mon_grouping; /* "" */
char *positive_sign; /* "" */
char *negative_sign; /* "" */
char *currency_symbol; /* "" */
char frac_digits; /* CHAR_MAX */
char p_cs_precedes; /* CHAR_MAX */
char n_cs_precedes; /* CHAR_MAX */
char p_sep_by_space; /* CHAR_MAX */
char n_sep_by_space; /* CHAR_MAX */
char p_sign_posn; /* CHAR_MAX */
char n_sign_posn; /* CHAR_MAX */
char *int_curr_symbol; /* "" */
char int_frac_digits; /* CHAR_MAX */
char int_p_cs_precedes; /* CHAR_MAX */
char int_n_cs_precedes; /* CHAR_MAX */
char int_p_sep_by_space; /* CHAR_MAX */
char int_n_sep_by_space; /* CHAR_MAX */
char int_p_sign_posn; /* CHAR_MAX */
char int_n_sign_posn; /* CHAR_MAX */
};
contains members related to the formatting of numeric values. in the "C" locale, its members have the values shown in the comments above. yes, all of them. every single one. the empty strings and CHAR_MAX are literally the defaults, look at the receipts. ๐งพโจ
Conforming to: C11 and later; POSIX.1-2001 and later.
See also: setlocale(3), localeconv(3), charsets(5), locale(7)
๐ฐ ldiv_t
Include: <stdlib.h>.
okay bestie that's where part one leaves us โ mid ldiv_t, cliffhanger energy, I know. ๐ญ more types are coming in the next part, don't go anywhere. ๐ฆ
๐ธ ldiv_t ๐ธ
- Include:
<stdlib.h>
typedef struct {
long quot; /* Quotient */
long rem; /* Remainder */
} ldiv_t;
It's literally the type of the value that ldiv(3) hands back to you. quot, rem, done ๐
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
ldiv(3)
๐ง lldiv_t ๐ง
- Include:
<stdlib.h>
typedef struct {
long long quot; /* Quotient */
long long rem; /* Remainder */
} lldiv_t;
Same vibe as ldiv_t but make it long long bestie. It's the type of the value returned by the lldiv(3) function.
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
lldiv(3)
๐ฆ off_t ๐ฆ
- Include:
<sys/types.h>. Alternatively,<aio.h>,<fcntl.h>,<stdio.h>,<sys/mman.h>,<sys/stat.h.h>, or<unistd.h>.
Used for file sizes. According to POSIX, this shall be a signed integer type.
- Versions:
<aio.h>and<stdio.h>defineoff_tsince POSIX.1-2008. - Conforming to: POSIX.1-2001 and later.
- Notes: On some architectures, the width of this type can be controlled with the feature test macro
_FILE_OFFSET_BITS. ๐ yes that's the one you keep hearing about. - See also:
lseek(2),mmap(2),posix_fadvise(2),pread(2),truncate(2),fseeko(3),lockf(3),posix_fallocate(3),feature_test_macros(7)
๐ pid_t ๐
- Include:
<sys/types.h>. Alternatively,<fcntl.h>,<sched.h>,<signal.h>,<spawn.h>,<sys/msg.h>,<sys/sem.h>,<sys/shm.h>,<sys/wait.h>,<termios.h>,<time.h>,<unistd.h>, or<utmpx.h>.
This type is used for storing process IDs, process group IDs, and session IDs. According to POSIX, it shall be a signed integer type, and the implementation shall support one or more programming environments where the width of pid_t is no greater than the width of the type long.
- Conforming to: POSIX.1-2001 and later.
- See also:
fork(2),getpid(2),getppid(2),getsid(2),gettid(2),getpgid(2),kill(2),pidfd_open(2),sched_setscheduler(2),waitpid(2),sigqueue(3),credentials(7),
not me noticing that trailing comma at the end of the See also list. it's giving original-manpage energy, we keep it fr fr ๐ซถ
โจ ptrdiff_t โจ
- Include:
<stddef.h>.
Used for a count of elements, and array indices. It is the result of subtracting two pointers. According to the C language standard, it shall be a signed integer type capable of storing values in the range [PTRDIFF_MIN, PTRDIFF_MAX].
The length modifier for ptrdiff_t for the printf(3) and the scanf(3) families of functions is t; resulting commonly in %td or %ti for printing ptrdiff_t values.
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also: the
size_tandssize_ttypes in this page.
๐ regex_t ๐
- Include:
<regex.h>.
typedef struct {
size_t re_nsub; /* Number of parenthesized subexpressions. */
} regex_t;
This is a structure type used in regular expression matching. It holds a compiled regular expression, compiled with regcomp(3). so like, the glow-up version of your regex, pre-chewed and ready ๐
- Conforming to: POSIX.1-2001 and later.
- See also:
regex(3)
๐ regmatch_t ๐
- Include:
<regex.h>.
typedef struct {
regoff_t rm_so; /* Byte offset from start of string
to start of substring */
regoff_t rm_eo; /* Byte offset from start of string of
the first character after the end of
substring */
} regmatch_t;
This is a structure type used in regular expression matching. it's the little receipt telling you where the match landed ๐
- Conforming to: POSIX.1-2001 and later.
- See also:
regexec(3)
๐ regoff_t ๐
- Include:
<regex.h>.
According to POSIX, it shall be a signed integer type capable of storing the largest value that can be stored in either a ptrdiff_t type or a ssize_t type.
- Versions: Prior to POSIX.1-2008, the type was capable of storing the largest value that can be stored in either an
off_ttype or assize_ttype. - Conforming to: POSIX.1-2001 and later.
- See also: the
regmatch_tstructure and theptrdiff_tandssize_ttypes in this page.
๐ฅ sigevent ๐ฅ
- Include:
<signal.h>. Alternatively,<aio.h>,<mqueue.h>, or<time.h>.
struct sigevent {
int sigev_notify; /* Notification type */
int sigev_signo; /* Signal number */
union sigval sigev_value; /* Signal value */
void (*sigev_notify_function)(union sigval);
/* Notification function */
pthread_attr_t *sigev_notify_attributes;
/* Notification attributes */
};
For further details about this type, see sigevent(7).
- Versions:
<aio.h>and<time.h>definesigeventsince POSIX.1-2008. - Conforming to: POSIX.1-2001 and later.
- See also:
timer_create(2),getaddrinfo_a(3),lio_listio(3),mq_notify(3)
See also the aiocb structure in this page.
โญ siginfo_t โญ
- Include:
<signal.h>. Alternatively,<sys/wait.h>.
typedef struct {
int si_signo; /* Signal number */
int si_code; /* Signal code */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
void *si_addr; /* Address of faulting instruction */
int si_status; /* Exit value or signal */
union sigval si_value; /* Signal value */
} siginfo_t;
Information associated with a signal. For further details on this structure (including additional, Linux-specific fields), see sigaction(2). lowkey it's the whole tea about what just happened to your process ๐ญ
- Conforming to: POSIX.1-2001 and later.
- See also:
pidfd_send_signal(2),rt_sigqueueinfo(2),sigaction(2),sigwaitinfo(2),psiginfo(3)
๐ซถ sigset_t ๐ซถ
- Include:
<signal.h>. Alternatively,<spawn.h>, or<sys/select.h>.
This is a type that represents a set of signals. According to POSIX, this shall be an integer or structure type.
- Conforming to: POSIX.1-2001 and later.
- See also:
epoll_pwait(2),ppoll(2),pselect(2),sigaction(2),signalfd(2),sigpending(2),sigprocmask(2),sigsuspend(2),sigwaitinfo(2),signal(7)
๐ sigval ๐
- Include:
<signal.h>.
union sigval {
int sigval_int; /* Integer value */
void *sigval_ptr; /* Pointer value */
};
Data passed with a signal.
- Conforming to: POSIX.1-2001 and later.
- See also:
pthread_sigqueue(3),sigqueue(3),sigevent(7)
See also the sigevent structure and the siginfo_t type in this page.
๐ size_t ๐
- Include:
<stddef.h>or<sys/types.h>. Alternatively,<aio.h>,<glob.h>,<grp.h>,<iconv.h>,<monetary.h>,<mqueue.h>,<ndbm.h>,<pwd.h>,<regex.h>,<search.h>,<signal.h>,<stdio.h>,<stdlib.h>,<string.h>,<strings.h>,<sys/mman.h>,<sys/msg.h>,<sys/sem.h>,<sys/shm.h>,<sys/socket.h>,<sys/uio.h>,<time.h>,<unistd.h>,<wchar.h>, or<wordexp.h>.
Used for a count of bytes. It is the result of the sizeof operator. According to the C language standard, it shall be an unsigned integer type capable of storing values in the range [0, SIZE_MAX]. According to POSIX, the implementation shall support one or more programming environments where the width of size_t is no greater than the width of the type long.
The length modifier for size_t for the printf(3) and the scanf(3) families of functions is z; resulting commonly in %zu or %zx for printing size_t values.
- Versions:
<aio.h>,<glob.h>,<grp.h>,<iconv.h>,<mqueue.h>,<pwd.h>,<signal.h>, and<sys/socket.h>definesize_tsince POSIX.1-2008. - Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
read(2),write(2),fread(3),fwrite(3),memcmp(3),memcpy(3),memset(3),offsetof(3)
See also the ptrdiff_t and ssize_t types in this page.
๐ธ 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 values at least in the range [-1, SSIZE_MAX], and the implementation 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 functions, which is z; resulting commonly in %zd or %zi for printing ssize_t values. Although z works for ssize_t on most implementations, portable POSIX programs should avoid using itโfor example, by converting the value to intmax_t and using its length modifier (j).
bestie listen: "works on most implementations" is NOT the same as "portable". don't be out here being messy in code that has to travel โ
- 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.
๐ง suseconds_t ๐ง
- Include:
<sys/types.h>. Alternatively,<sys/select.h>, or<sys/time.h>.
Used for time in microseconds. According to POSIX, it shall be a signed integer type capable of storing values at least in the range [-1, 1000000], and the implementation shall support one or more programming environments where the width of suseconds_t is no greater than the width of the type long.
- Conforming to: POSIX.1-2001 and later.
- See also: the
timevalstructure in this page.
โฐ time_t โฐ
- Include:
<time.h>or<sys/types.h>. Alternatively,<sched.h>,<sys/msg.h>,<sys/select.h>,<sys/sem.h>,<sys/shm.h>,<sys/stat.h>,<sys/time.h>, or<utime.h>.
Used for time in seconds. According to POSIX, it shall be an integer type.
- Versions:
<sched.h>definestime_tsince POSIX.1-2008. - Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
stime(2),time(2),ctime(3),difftime(3)
๐ timer_t ๐
- Include:
<sys/types.h>. Alternatively,<time.h>.
Used for timer ID returned by timer_create(2). According to POSIX, there are no defined comparison or assignment operators for this type.
no comparing, no assigning, no copying. it's giving โจmysteryโจ. treat it as an opaque little treasure and don't go poking at its insides ๐
- Conforming to: POSIX.1-2001 and later.
and the see-also for the entry right before this one finishes up with: timer_create(2), timer_delete(2), timer_getoverrun(2), timer_settime(2). cute. carry on ๐
timespec
Include: <time.h>. Alternatively, <aio.h>, <mqueue.h>, <sched.h>, <signal.h>, <sys/select.h>, or <sys/stat.h>.
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
bestie this one describes times in seconds and nanoseconds โจ
- Conforming to: C11 and later; POSIX.1-2001 and later.
- See also:
clock_gettime(2),clock_nanosleep(2),nanosleep(2),timerfd_gettime(2),timer_gettime(2)
timeval
Include: <sys/time.h>. Alternatively, <sys/resource.h>, <sys/select.h>, or <utmpx.h>.
struct timeval {
time_t tv_sec; /* Seconds */
suseconds_t tv_usec; /* Microseconds */
};
describes times in seconds and microseconds, no cap ๐ซถ
- Conforming to: POSIX.1-2001 and later.
- See also:
gettimeofday(2),select(2),utimes(2),adjtime(3),futimes(3),timeradd(3)
uid_t
Include: <sys/types.h>. Alternatively, <pwd.h>, <signal.h>, <stropts.h>, <sys/ipc.h>, <sys/stat.h>, or <unistd.h>.
a type used to hold user IDs. according to POSIX, this shall be an integer type โ periodt.
- Conforming to: POSIX.1-2001 and later.
- See also:
chown(2),getuid(2),geteuid(2),getresuid(2),getpwnam(2),credentials(7)
uintmax_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
an unsigned integer type capable of representing any value of any unsigned integer type supported by the implementation. according to the C language standard, it shall be capable of storing values in the range [0, UINTMAX_MAX]. the range, the whole range, and nothing but the range ๐
the macro UINTMAX_C() expands its argument to an integer constant of type uintmax_t.
the length modifier for uintmax_t for the printf(3) and the scanf(3) families of functions is j; resulting commonly in %ju or %jx for printing uintmax_t values. iykyk.
- Conforming to: C99 and later; POSIX.1-2001 and later.
Bugs:uintmax_tis not large enough to represent values of typeunsigned __int128in implementations whereunsigned __int128is defined andunsigned long longis less than 128 bits wide. ๐ญ not the big type being too small.
- See also: the
intmax_ttype in this page.
uintN_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
uint8_t, uint16_t, uint32_t, uint64_t
an unsigned integer type of a fixed width of exactly N bits, N being the value specified in its type name. according to the C language standard, they shall be capable of storing values in the range [0, UINTN_MAX], substituting N by the appropriate number. so exact. so iconic. ๐
according to POSIX, uint8_t, uint16_t, and uint32_t are required; uint64_t is only required in implementations that provide integer types with width 64; and all other types of this form are optional.
the length modifiers for the uintN_t types for the printf(3) family of functions are expanded by macros of the forms PRIuN, PRIoN, PRIxN, and PRIXN (defined in <inttypes.h>); resulting for example in %"PRIu32" or %"PRIx32" for printing uint32_t values. the length modifiers for the uintN_t types for the scanf(3) family of functions are expanded by macros of the forms SCNuN, SCNoN, SCNxN, and SCNXN (defined in <inttypes.h>); resulting for example in %"SCNu16" or %"SCNx16" for scanning uint16_t values. literally the macros are doing the most and i love them for it ๐
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also: the
intmax_t,intN_t, anduintmax_ttypes in this page.
uintptr_t
Include: <stdint.h>. Alternatively, <inttypes.h>.
an unsigned integer type such that any valid (void *) value can be converted to this type and back. according to the C language standard, it shall be capable of storing values in the range [0, UINTPTR_MAX]. a whole round trip, bestie, we love a safe return ๐ฆ
the length modifier for uintptr_t for the printf(3) family of functions is expanded by the macros PRIuPTR, PRIoPTR, PRIxPTR, and PRIXPTR (defined in <inttypes.h>); resulting commonly in %"PRIuPTR" or %"PRIxPTR" for printing uintptr_t values. the length modifier for uintptr_t for the scanf(3) family of functions is expanded by the macros SCNuPTR, SCNoPTR, SCNxPTR, and SCNXPTR (defined in <inttypes.h>); resulting commonly in %"SCNuPTR" or %"SCNxPTR" for scanning uintptr_t values.
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also: the
intptr_tandvoid *types in this page.
va_list
Include: <stdarg>. Alternatively, <stdio.h>, or <wchar.h>.
used by functions with a varying number of arguments of varying types. the function must declare an object of type va_list which is used by the macros va_start(3), va_arg(3), va_copy(3), and va_end(3) to traverse the list of arguments. the girlies who wander the argument list ๐ง
- Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
va_start(3),va_arg(3),va_copy(3),va_end(3)
void *
according to the C language standard, a pointer to any object type may be converted to a pointer to void and back. POSIX further requires that any pointer, including pointers to functions, may be converted to a pointer to void and back.
conversions from and to any other pointer type are done implicitly, not requiring casts at all. note that this feature prevents any kind of type checking: the programmer should be careful not to convert a void * value to a type incompatible to that of the underlying data, because that would result in undefined behavior. ๐ no vibe check, no safety net, just chaos.
this type is useful in function parameters and return value to allow passing values of any type. the function will typically use some mechanism to know the real type of the data being passed via a pointer to void.
a value of this type can't be dereferenced, as it would give a value of type void, which is not possible. likewise, pointer arithmetic is not possible with this type. however, in GNU C, pointer arithmetic is allowed as an extension to the standard; this is done by treating the size of a void or of a function as 1. a consequence of this is that sizeof is also allowed on void and on function types, and returns 1. GNU C said "rules are a suggestion" โจ
the conversion specifier for void * for the printf(3) and the scanf(3) families of functions is p.
- Versions: The POSIX requirement about compatibility between
void *and function pointers was added in POSIX.1-2008 Technical Corrigendum 1 (2013). - Conforming to: C99 and later; POSIX.1-2001 and later.
- See also:
malloc(3),memcmp(3),memcpy(3),memset(3) - See also the
intptr_tanduintptr_ttypes in this page.
โจ NOTES โจ
the structures described in this manual page shall contain, at least, the members shown in their definition, in no particular order. so don't come for the member order, it's a free country ๐
most of the integer types described in this page don't have a corresponding length modifier for the printf(3) and the scanf(3) families of functions. to print a value of an integer type that doesn't have a length modifier, it should be converted to intmax_t or uintmax_t by an explicit cast. to scan into a variable of an integer type that doesn't have a length modifier, an intermediate temporary variable of type intmax_t or uintmax_t should be used. when copying from the temporary variable to the destination variable, the value could overflow. if the type has upper and lower limits, the user should check that the value is within those limits, before actually copying the value. the example below shows how these conversions should be done. bestie please do the range check, i am begging ๐
Conventions used in this page
in "Conforming to" we only concern ourselves with C99 and later and POSIX.1-2001 and later. some types may be specified in earlier versions of one of these standards, but in the interests of simplicity we omit details from earlier standards. we're keeping it light โจ
in "Include", we first note the "primary" header(s) that define the type according to either the C or POSIX.1 standards. under "Alternatively", we note additional headers that the standards specify shall define the type.
๐ EXAMPLES ๐
the program shown below scans from a string and prints a value stored in a variable of an integer type that doesn't have a length modifier. the appropriate conversions from and to intmax_t, and the appropriate range checks, are used as explained in the notes section above. main character code fr fr ๐
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
int
main (void)
{
static const char *const str = "500000 us in half a second";
suseconds_t us;
intmax_t tmp;
/* Scan the number from the string into the temporary variable */
sscanf(str, "%jd", &tmp);
/* Check that the value is within the valid range of suseconds_t */
if (tmp < -1 || tmp > 1000000) {
fprintf(stderr, "Scanned value outside valid range!\n");
exit(EXIT_FAILURE);
}
/* Copy the value to the suseconds_t variable 'us' */
us = tmp;
/* Even though suseconds_t can hold the value -1, this isn't
a sensible number of microseconds */
if (us < 0) {
fprintf(stderr, "Scanned value shouldn't be negative!\n");
exit(EXIT_FAILURE);
}
/* Print the value */
printf("There are %jd microseconds in half a second.\n",
(intmax_t) us);
exit(EXIT_SUCCESS);
}
๐ซถ SEE ALSO ๐ซถ
๐ COLOPHON ๐
this page is part of release 5.10 of the Linux man-pages project. a description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
and that's a wrap, bestie โ this little masterpiece is from the Linux fam, dated 2020-12-21, filed under SYSTEM_DATA_TYPES(7). you understood the whole thing, no cap, i'm so proud of you ๐โจ๐ธ
๐ฆ where this page comes from
- ubuntu jammy: manpages 5.10-1ubuntu1 ยท GPL-2.0-or-later
- Copyright (c) 2020 by Alejandro Colomar <colomar.6.4.3@gmail.com>
- Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms