VirtualBox

Changeset 60964 in vbox for trunk/include/iprt/cdefs.h


Ignore:
Timestamp:
May 12, 2016 7:06:30 PM (9 years ago)
Author:
vboxsync
Message:

iprt/cdefs.h: Added RT_CLANG_PREREQ macros. Added RT_NOREF_PV macro that uses _Pragma("unused(xxx)") instead of (void)(var), just in case we'll need it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

    r60843 r60964  
    218218#define RT_MSC_VER_VC140    RT_MSC_VER_VS2015   /**< Visual C++ 14.0, aka Visual Studio 2015. */
    219219/** @} */
     220
     221/** @def RT_CLANG_PREREQ
     222 * Shorter than fiddling with __clang_major__ and __clang_minor__.
     223 *
     224 * @param   a_MinMajor      Minimum major version
     225 * @param   a_MinMinor      The minor version number part.
     226 */
     227#define RT_CLANG_PREREQ(a_MinMajor, a_MinMinor)      RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
     228/** @def RT_CLANG_PREREQ_EX
     229 * Simplified way of checking __clang_major__ and __clang_minor__ regardless of
     230 * actual compiler used, returns @a a_OtherRet for other compilers.
     231 *
     232 * @param   a_MinMajor      Minimum major version
     233 * @param   a_MinMinor      The minor version number part.
     234 * @param   a_OtherRet      What to return for non-GCC compilers.
     235 */
     236#if defined(__clang_major__) && defined(__clang_minor__)
     237# define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) \
     238    ((__clang_major__ << 16) + __clang_minor__ >= ((a_MinMajor) << 16) + (a_MinMinor))
     239#else
     240# define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
     241#endif
     242
    220243
    221244/** @def __X86__
     
    27062729
    27072730/** @def NOREF
    2708  * Keeps the compiler from bitching about an unused parameter.
     2731 * Keeps the compiler from bitching about an unused parameter, local variable,
     2732 * or other stuff, will never use _Pragma are is thus more flexible.
    27092733 */
    27102734#define NOREF(var)               (void)(var)
     2735
     2736/** @def RT_NOREF_PV
     2737 * Keeps the compiler from bitching about an unused parameter or local variable.
     2738 * This one cannot be used with structure members and such, like for instance
     2739 * AssertRC may end up doing due to its generic nature.
     2740 */
     2741#if defined(__cplusplus) && RT_CLANG_PREREQ(6, 0)
     2742# define RT_NOREF_PV(var)       _Pragma(RT_STR(unused(var)))
     2743#else
     2744# define RT_NOREF_PV(var)       (void)(var)
     2745#endif
    27112746
    27122747/** @def RT_BREAKPOINT
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette