What's the C++ equivalent of UINT32_MAX?

前端 未结 5 1749
广开言路
广开言路 2021-02-02 07:27

In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t data type. However, in C++ the UINT32_MAX gets d

5条回答
  •  悲&欢浪女
    2021-02-02 07:54

    Well, uint32_t will always be 32 bit, and always be unsigned, so you can safely define it manually:

    #define UINT32_MAX  (0xffffffff)
    

    You can also do

    #define UINT32_MAX  ((uint32_t)-1)
    

提交回复
热议问题