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

前端 未结 4 705
误落风尘
误落风尘 2020-12-07 19:47

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

相关标签:
4条回答
  • 2020-12-07 20:06

    Those integer types are all defined in stdint.h

    0 讨论(0)
  • 2020-12-07 20:12

    The questioner actually asked about int16 (etc) rather than (ugly) int16_t (etc).

    There are no standard headers - nor any in Linux's /usr/include/ folder that define them without the "_t".

    0 讨论(0)
  • 2020-12-07 20:29

    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.

    0 讨论(0)
  • 2020-12-07 20:31

    If you are using C99 just include stdint.h. BTW, the 64bit types are there iff the processor supports them.

    0 讨论(0)
提交回复
热议问题