File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1515
1616// Detect builtin bit_cast
1717#ifndef HAVE_BUILTIN_BIT_CAST
18+ /* Only use __builtin_bit_cast if the compiler has it AND
19+ we're compiling as C++ (GCC 11+) or as a C standard that supports it (C23+). */
1820 #if defined(__has_builtin )
1921 #if __has_builtin (__builtin_bit_cast )
20- #define HAVE_BUILTIN_BIT_CAST 1
22+ #if defined(__cplusplus ) || (defined(__STDC_VERSION__ ) && __STDC_VERSION__ >= 202311L )
23+ #define HAVE_BUILTIN_BIT_CAST 1
24+ #endif
2125 #endif
2226 #endif
23- /* GCC 11+ also has __builtin_bit_cast */
24- #if !defined(HAVE_BUILTIN_BIT_CAST ) && defined(__GNUC__ ) && !defined(__clang__ )
27+
28+ /* GCC note: in GCC 11–13, __builtin_bit_cast exists for C++ but NOT for C. */
29+ #if !defined(HAVE_BUILTIN_BIT_CAST ) && defined(__GNUC__ ) && !defined(__clang__ ) && defined(__cplusplus )
2530 #if __GNUC__ >= 11
2631 #define HAVE_BUILTIN_BIT_CAST 1
2732 #endif
You can’t perform that action at this time.
0 commit comments