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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux