SYSTEM_DATA_TYPES(7)

๐Ÿ“ฆ
version 5.10 ยท 2 versions
, in ubuntu jammy

๐Ÿ’– 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.

See also: times(2), clock(3)

๐Ÿ•ฐ๏ธ 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.

See also: mknod(2), stat(2)

โž— 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_t is double.
  • 1 โ€” double_t is double.
  • 2 โ€” double_t is long 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_t is float.
  • 1 โ€” float_t is double.
  • 2 โ€” float_t is long 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_t is not large enough to represent values of type __int128 in implementations where __int128 is defined and long long is 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.


๐Ÿ‘‘ 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.

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_t and ssize_t types 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_t type or a ssize_t type.
  • Conforming to: POSIX.1-2001 and later.
  • See also: the regmatch_t structure and the ptrdiff_t and ssize_t types 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).

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 ๐Ÿ˜ญ


๐Ÿซถ 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.


๐Ÿ“ sigval ๐Ÿ“

  • Include: <signal.h>.
union sigval {
    int     sigval_int; /* Integer value */
    void   *sigval_ptr; /* Pointer value */
};

Data passed with a signal.

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.

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 โœ‹

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 timeval structure 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.


๐ŸŽ€ 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 โœจ


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 ๐Ÿซถ


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.


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_t is not large enough to represent values of type unsigned __int128 in implementations where unsigned __int128 is defined and unsigned long long is less than 128 bits wide. ๐Ÿ˜ญ not the big type being too small.
  • See also: the intmax_t type 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, and uintmax_t types 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_t and void * 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 ๐Ÿงš


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_t and uintptr_t types 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