Should I use stdint.h types?

June Bug june at
Sat Jan 25 05:36:05 UTC 2020

> On Jan 23, 2020, at 21:38, Joe Nelson <joe at> wrote:
> If I'm working in C99 should I use the [u]int{,_least,_fast}N_t types,
> or continue using the C89 "classic" integer types?
> The stdint.h types clearly document intentions, although experienced C
> programmers are probably aware of the portable range of each classic
> type. The classic types are prettier, while the new types allow some
> combinations that weren't expressible before, like int_least32_t.
> I think I'd avoid the more rigid intN_t types because they don't exist
> on all machines.
> Any opinions?

I generally only use a few types: size_t for sizes/lengths/counts
etc., int and unsigned (typedef uint) for general integers where
size is unlikely to matter, and unsigned char (typedef byte).  It’s
not the ‘80s or ‘90s anymore and unless you’re writing specifically
for embedded platforms it’s safe to assume that int is “big enough”.
The _least and _fast variants also don’t seem generally applicable.
I’ll usually only use stdint.h types if some algorithm (such as a
hash function) or data format (such as PNG) calls for a specific
size like uint32_t.

More information about the Friends mailing list