What does the pointer size depend on in C++ on different platforms?


According to the C++ standard, the pointer size depends on the particular compiler implementation and does not relate directly to the platform capacity. In its turn, within the framework of a particular standard implementation, sizes of pointers of various types (pointers to objects, pointers to functions, etc.) may also vary.

However, most contemporary operating systems of general purpose (desktop UNIX-compatible systems, MS Windows) use data models where the pointer size corresponds to the capacity of the address bus employed by the architecture of these platforms. The address bus width determines the size of addressable memory. For example, if the address bus width is 32 bits and the memory word size is one byte (the minimal addressable data amount), then the size of the addressable memory equals 2^32 bytes, which determines the optimal pointer size to be used for this platform.

References



Use PVS-Studio to search for bugs in C, C++, C# and Java

We offer you to check your project code with PVS-Studio. Just one bug found in the project will show you the benefits of the static code analysis methodology better than a dozen of the articles.

goto PVS-Studio;



Bugs Found

Checked Projects
336
Collected Errors
12 743