This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ reinterpret cast from 32 bit pointer to long long


I am on a 32 bit machine but one of the system interfaces takes a 64 bit value for an address.

Can I (should I) trust g++ and just do something like

char *foo;
unsigned long long n = reinterpret_cast<unsigned long long>(foo);

or should I write a function to do something like:

char *foo;
unsigned long fl = reinterpret_cast<unsigned long>(foo);
unsigned long long n = (x00000000ffffffffLL & fl;

I have two worries: 1) It needs to be a 64 bit result. 2) The upper 32 bits to be zero filled, not sign extended.

Thanks,
Perry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]