--- title: Typedefs TARGET DECK: Obsidian::STEM FILE TAGS: c17::type tags: - c17 --- ## Overview The `` header defines a few standard `typedef`s: * `ptrdiff_t`: the signed integer type of the result of subtracting two pointers. * `size_t`: the unsigned integer type of the result of the `sizeof` operator. The standard often uses `typedef`s ending with `_t`. %%ANKI Basic What is the type of `x` in the following? ```c #define int_ptr int * int_ptr x, y; ``` Back: `int *` Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994. END%% %%ANKI Basic What is the type of `y` in the following? ```c #define int_ptr int * int_ptr x, y; ``` Back: `int` Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994. END%% %%ANKI Basic What is the type of `x` in the following? ```c typedef int_ptr int * int_ptr x, y; ``` Back: `int *` Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994. END%% %%ANKI Basic What is the type of `y` in the following? ```c typedef int_ptr int * int_ptr x, y; ``` Back: `int *` Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994. END%% %%ANKI Basic What header defines `size_t`? Back: `` Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic What header defines `ptrdiff_t`? Back: `` Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic `ptrdiff_t` is used as the type of what result? Back: Subtracting two pointers. Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic `size_t` is used as the type of what result? Back: The `sizeof` operation. Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic Is `ptrdiff_t` signed or unsigned? Back: Signed. Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic Is `size_t` signed or unsigned? Back: Unsigned. Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). END%% %%ANKI Basic The C standard typically suffixes `typedef`s with what? Back: `_t` Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). END%% ## Bibliography * “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). * Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). * Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.