ds 0.10.0
A C library to safely yet efficiently work with UTF-8–encoded, growable dynamic strings.
usize.h File Reference

Declaration of the usize type, related constants and functions. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for usize.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DS_USIZE_BYTES   ((ds_usize_t)sizeof (ds_usize_t))
 The size of usize in bytes. More...
 
#define DS_USIZE_MIN   ((ds_usize_t)0)
 The smallest value that can be represented by usize. More...
 
#define DS_USIZE_MAX   ((ds_usize_t)SIZE_MAX)
 The largest value that can be represented by usize (264 − 1 on 64-bit targets, 232 − 1 on 32-bit). More...
 
#define DS_SCN_USIZE   "zu"
 usize notation. Can be used in scanf to parse and read usize values. More...
 
#define DS_PRI_USIZE   "zu"
 usize notation. Can be used in printf to format and write usize values. More...
 

Typedefs

typedef size_t ds_usize_t
 The pointer-sized unsigned integer type. More...
 

Detailed Description

Declaration of the usize type, related constants and functions.

Author
Avinash Maddikonda (svass.nosp@m.saka.nosp@m.vi@gm.nosp@m.ail..nosp@m.com)
Since
0.1.0
Date
2023-07-24

Definition in file usize.h.

Macro Definition Documentation

◆ DS_PRI_USIZE

#define DS_PRI_USIZE   "zu"

usize notation. Can be used in printf to format and write usize values.

Examples

Basic usage:

printf ("%" DS_PRI_USIZE, x);
#define DS_PRI_USIZE
usize notation. Can be used in printf to format and write usize values.
Definition: usize.h:91
#define DS_USIZE_MAX
The largest value that can be represented by usize (264 − 1 on 64-bit targets, 232 − 1 on 32-bit).
Definition: usize.h:61
size_t ds_usize_t
The pointer-sized unsigned integer type.
Definition: usize.h:26

Definition at line 91 of file usize.h.

◆ DS_SCN_USIZE

#define DS_SCN_USIZE   "zu"

usize notation. Can be used in scanf to parse and read usize values.

Warning
It is strongly advised to use fgets instead of scanf to read input.

Examples

Basic usage:

scanf ("%" DS_SCN_USIZE, &x);
#define DS_SCN_USIZE
usize notation. Can be used in scanf to parse and read usize values.
Definition: usize.h:78

Definition at line 78 of file usize.h.

◆ DS_USIZE_BYTES

#define DS_USIZE_BYTES   ((ds_usize_t)sizeof (ds_usize_t))

The size of usize in bytes.

Examples

Basic usage:

assert (DS_USIZE_BYTES == sizeof (size_t));
#define DS_USIZE_BYTES
The size of usize in bytes.
Definition: usize.h:37

Definition at line 37 of file usize.h.

◆ DS_USIZE_MAX

#define DS_USIZE_MAX   ((ds_usize_t)SIZE_MAX)

The largest value that can be represented by usize (264 − 1 on 64-bit targets, 232 − 1 on 32-bit).

Examples

Basic usage:

assert (DS_USIZE_MAX == SIZE_MAX);

Definition at line 61 of file usize.h.

◆ DS_USIZE_MIN

#define DS_USIZE_MIN   ((ds_usize_t)0)

The smallest value that can be represented by usize.

Examples

Basic usage:

assert (DS_USIZE_MIN == 0);
#define DS_USIZE_MIN
The smallest value that can be represented by usize.
Definition: usize.h:49

Definition at line 49 of file usize.h.

Typedef Documentation

◆ ds_usize_t

typedef size_t ds_usize_t

The pointer-sized unsigned integer type.

The size of this type, DS_USIZE_BYTES, is how many bytes it takes to reference any location in memory. For example, on a 32 bit target, this is 4 bytes and on a 64 bit target, this is 8 bytes.

Definition at line 26 of file usize.h.