On the 32-bit machine, why the size of a pointer is 32-bit? Why not 16-bit or 64-bit? What’s the cons and pros?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because it mimics the size of the actual “pointers” in assembler. On a machine with a 64 bit address bus, it will be 64 bits. In the old 6502, it was an 8 bit machine, but it had 16 bit address bus so that it could address 64K of memory. On most 32 bit machines, 32 bits were enough to address all the memory, so that’s what the pointer size was in C++. I know that some of the early M68000 series chips only had a 24 bit memory address space, but it was addressed from a 32 bit register so even on those the pointer would be 32 bits.
In the bad old days of the 80286, it was worse – there was a 16 bit address register, and a 16 bit segment register. Some C++ compilers didn’t hide that from you, and made you declare your pointers as
nearorfardepending on whether you wanted to change the segment register. Mercifully, I’ve recycled most of those brain cells, so I forget ifnearpointers were 16 bits – but at the machine level, they would be.