Type of unsigned long is different from uint32_t and uint64_t on Windows (VS2010)

孤者浪人 提交于 2019-12-01 17:32:25

There are two distinct 32-bit, unsigned types

Yes, there are. Both int and long are represented by 32 bits.

Is this allowed by the C++ standard?

Yes. The specification states (C++11 §3.9.1[basic.fundamental]/2):

There are five standard signed integer types : signed char, short int, int, long int, and long long int. In this list, each type provides at least as much storage as those preceding it in the list.

For each of the standard signed integer types, there exists a corresponding (but different) standard unsigned integer type...each of which occupies the same amount of storage and has the same alignment requirements as the corresponding signed integer type

Note that despite the fact that int and long are represented by the same number of bits, they are still different types (so, for example, they are treated differently during overload resolution).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!