VirtualBox

Changeset 97965 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jan 3, 2023 9:57:14 PM (2 years ago)
Author:
vboxsync
Message:

iprt/assertcompile.h: 2nd attempt at fixing the problem that some gcc & clang versions annoyance at RTASSERTVAR being declared both within and outside RT_C_DECLS_BEGIN/END.

File:
1 edited

Legend:

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

    r97964 r97965  
    103103 */
    104104#ifdef __GNUC__
    105 # ifdef __cplusplus
    106 #  define AssertCompileNS(expr)  extern "C" int RTASSERTVAR[1] __attribute__((__unused__)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
     105# ifdef __cplusplus /* Hack alert! Some GCC versions and clang gets upset when the macro is used both inside and outside
     106                                   extern "C". So, making the variable a bit more unique by appending the line number. */
     107#  define AssertCompileNS(expr)  extern int RT_CONCAT(RTASSERTVAR,__LINE__)[1] __attribute__((__unused__)), \
     108                                            RT_CONCAT(RTASSERTVAR,__LINE__)[(expr) ? 1 : 0] __attribute__((__unused__))
    107109# else
    108110#  define AssertCompileNS(expr)  extern int RTASSERTVAR[1] __attribute__((__unused__)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
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