Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


In <sal/types.h> we have:

/** Wrap C++ const_cast, reinterpret_cast and static_cast expressions in
    macros to keep code portable to old compilers (since most compilers still
    lack RTTI support, dynamic_cast is not included here).
 */
#ifdef __cplusplus
#if defined SAL_W32 || defined SOLARIS || defined LINUX || defined MACOSX || \
    defined FREEBSD || defined NETBSD || defined AIX || \
    defined OPENBSD || defined DRAGONFLY
#define SAL_CONST_CAST(type, expr) (const_cast< type >(expr))
#define SAL_REINTERPRET_CAST(type, expr) (reinterpret_cast< type >(expr))
#define SAL_STATIC_CAST(type, expr) (static_cast< type >(expr))
#else /* SAL_W32, SOLARIS, LINUX */
#define SAL_CONST_CAST(type, expr) ((type) (expr))
#define SAL_REINTERPRET_CAST(type, expr) ((type) (expr))
#define SAL_STATIC_CAST(type, expr) ((type) (expr))
#endif /* SAL_W32, SOLARIS, LINUX */
#endif /* __cplusplus */

Does the #else branch make any sense any more? Is there any OS for
which the #else branch would be needed? And why do we test the OS here
anyway, shouldn't we be testing the compiler and perhaps compiler
version?

Should this be simplified to always expand to the C++-style casts, and
then an Easy Hack added to do the expansion inline so that we can get
rid of the then pointless macros?

(The lack of ANDROID and IOS in the test is just an oversight, I will
add them there.)

(SAL_REINTERPRET_CAST is not used anywhere, says opengrok, so that can
be binned outright.)

--tml

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.