Stephan Bergmann wrote:
[...]
- Added SAL_INT_CAST (for C) and std::static_int_cast and
std::reinterpret_int_cast (for C++) to sal/types.h and brought in
sal_IntPtr and sal_uIntPtr to sal/types.h from CWS ooo64bit02. See the
documentation in sal/types.h for when this new functionality should be
used.
Just dropped std::reinterpret_int_cast again (and changed documentation
of SAL_INT_CAST to disallow casting between integer and pointer types),
as a plain reinterpret_cast is sufficient. The following is a little
cookbook of how to cast between pointer and integer types.
C++:
====
From pointer-to-(possibly-cv-qualified-)void-or-object type P to
unsigned integral type U:
P p;
U u = sal::static_int_cast< U >(
reinterpret_cast< sal_uIntPtr >(p));
From unsigned integral type U to
pointer-to-(possibly-cv-qualified-)void-or-object type P:
U u;
P p = reinterpret_cast< P >(
sal::static_int_cast< sal_uIntPtr >(u));
From pointer-to-(possibly-cv-qualified-)void-or-object type P to signed
integral type S:
P p;
S s = sal::static_int_cast< S >(
reinterpret_cast< sal_uIntPtr >(p));
From signed integral type S to
pointer-to-(possibly-cv-qualified-)void-or-object type P:
S s;
P p = reinterpret_cast< P >(
sal::static_int_cast< sal_uIntPtr >(s));
C:
==
From pointer-to-(possibly-qualified-)void-or-object type P to unsigned
integer type U:
P p;
U u = SAL_INT_CAST(U, (sal_uIntPtr) p);
From unsigned integer type U to
pointer-to-(possibly-qualified-)void-or-object type P:
U u;
P p = (P) SAL_INT_CAST(sal_uIntPtr, u);
From pointer-to-(possibly-qualified-)void-or-object type P to signed
integer type S:
P p;
S s = SAL_INT_CAST(S, (sal_uIntPtr) p);
From signed integer type S to
pointer-to-(possibly-qualified-)void-or-object type P:
S s;
P p = (P) SAL_INT_CAST(sal_uIntPtr, s);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]