UL suffix vs uint32_t cast
问题 I have to define constants like this : #define MY_CONSTANT 0xBEEF I want to be sure that my constant will be considered 32 bits. I have can use a (uint32_t) cast like this : #define MY_CONSTANT (uint32_t)0xBEEF Or a UL suffix like this : #define MY_CONSTANT 0xBEEFUL Are these two versions fully equivalent? I would say no, as UL is the equivalent of unsigned long and unsigned long length may depend on CPU. The C99 standard ensures that an uint32_t integer is 32 bits, but I don't think it