Changeset 97969 in vbox
- Timestamp:
- Jan 3, 2023 11:06:19 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155060
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/assertcompile.h
r97967 r97969 67 67 * It has no other function and shouldn't be used. 68 68 * 69 * GCC and IBM VisualAge C/C++ uses this, though GCC doesn't need this global 70 * scope one as it declares it for each use. 71 */ 72 #ifndef __GNUC__ 69 * GCC and IBM VisualAge C/C++ uses this. GCC doesn't technicaly need this 70 * global scope one as it declares it for each use, however things get 71 * complicated in C++ code where most GCC and clang versions gets upset by mixed 72 * "C" and "C++" versions of the symbol when using inside and outside 73 * RT_C_DECLS_BEGIN/END. The GCC 3.3.x and 3.4.x versions we use, OTOH will 74 * always complain about unused RTASSERTVAR for each AssertCompileNS use in a 75 * function if we declare it globally, so we don't do it for those, but we do 76 * for 4.x+ to prevent linkage confusion. 77 */ 78 #if !defined(__cplusplus) || !defined(__GNUC__) 73 79 extern int RTASSERTVAR[1]; 80 #elif RT_GNUC_PREREQ(4, 0) || defined(__clang_major__) /* Not sure when they fixed the global scoping __unused__/whatever problem. */ 81 RT_C_DECLS_BEGIN 82 extern int RTASSERTVAR[1]; 83 RT_C_DECLS_END 74 84 #endif 75 85 … … 103 113 */ 104 114 #ifdef __GNUC__ 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 unqiue by means on __COUNTER__ or __LINE__. 107 Note! __COUNTER__ may upset precompiled headers, but this macro only applies to 108 gcc 4.2.x and older, so probably not a big issue. */ 109 # ifdef __COUNTER__ 110 # define AssertCompileNS(expr) AssertCompileNS2(expr, RT_CONCAT(RTASSERTVAR, __COUNTER__)) 111 # else 112 # define AssertCompileNS(expr) AssertCompileNS2(expr, RT_CONCAT(RTASSERTVAR, __LINE__)) 113 # endif 114 # define AssertCompileNS2(expr,a_VarName) extern int a_VarName[ 1 ] __attribute__((__unused__)), \ 115 # define AssertCompileNS(expr) AssertCompileNS2(expr,RTASSERTVAR) 116 # define AssertCompileNS2(expr,a_VarName) extern int a_VarName[ 1 ] __attribute__((__unused__)), \ 115 117 a_VarName[(expr) ? 1 : 0] __attribute__((__unused__)) 116 # else117 # define AssertCompileNS(expr) extern int RTASSERTVAR[1] __attribute__((__unused__)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))118 # endif119 118 #elif defined(__IBMC__) || defined(__IBMCPP__) 120 119 # define AssertCompileNS(expr) extern int RTASSERTVAR[(expr) ? 1 : 0]
Note:
See TracChangeset
for help on using the changeset viewer.