Search code examples
clibc

Are types like uint32, int32, uint64, int64 defined in any stdlib header?


I often see source code using types like uint32, uint64 and I wonder if they should be defined by the programmer in the application code or if they are defined in a standard lib header.

What's the best way to have these types on my application source code?


Solution

  • The C99 stdint.h defines these:

    • int8_t
    • int16_t
    • int32_t
    • uint8_t
    • uint16_t
    • uint32_t

    And, if the architecture supports them:

    • int64_t
    • uint64_t

    There are various other integer typedefs in stdint.h as well.

    If you're stuck without a C99 environment then you should probably supply your own typedefs and use the C99 ones anyway.

    The uint32 and uint64 (i.e. without the _t suffix) are probably application specific.