clinker

How can <stdint.h> types guarantee bit width?


Since C is a loosely typed language and stdint.h defines just typedefs (I assume), how can the widths of ints be guaranteed?

What I am asking is about the implementation rather than the library usage.


Solution

  • stdint.h is part of the C implementation, which defines the typedefs using whatever underlying types are appropriate for that implementation. It's not a portable file you can carry to any C implementation you like.