Archived

This topic is now archived and is closed to further replies.

LukeSkyRunner

Pointers alocation

Recommended Posts

It''ll typically depend on the OS and/or memory addressing scheme of the computer you''re running on. For most computers that means it''ll be 32 bits.

Share this post


Link to post
Share on other sites
It generally doesn''t depend on the datatype. On i386-based architectures, it''s almost always 4 bytes. On other architectures, it may be different. The size of a pointer is generally the same as the bus width, so ia64 has 8-byte pointers.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
It used to vary wildy based on platform and architeture ... then most common architechtures became 32 bit AND settled on using uniform flat memory models, so it didn''t matter for most cases. Now 64 bit computers are out, and so are hybrid 64 bit address, 32 bit computation computers, and so are NUMA (Non Uniform Memory Architecture) systems ... so once again it can be complicated.

It almost never would depend on data "type" in the C++ sense, it would depend on data "location" in the sense of where in the OS it is comming from. And it is not really poosible for compilers to handle this cleanly ... so here''s the normal case:

in C++ - if the platform uses 32 bit pointers, all pointers will be 32 bit, UNLESS some special keyword is user in their decalration (aka old "near" and "far"). If the platform uses 64 bit addressing (and by platform I really mean the COMPILATION MODE you are compling in .. cause compiling with 32 settings, will still use 32 bit addresses ... even on a 64 bit platform) then all addresses will be 64, unless some keyword says otherwise, OR the compiler optimizes some code ... such as uses 32 bit addressing automatically for stack variables (no need for 64 bits when local - but I''m not sure if any comps do this or not - it may be a pessimization anyway).

Share this post


Link to post
Share on other sites