Skip to content
Snippets Groups Projects
  • Alexandre Oliva's avatar
    67be156f
    [libstdc++] add _GLIBCXX_CLANG to workaround predefined __clang__ · 67be156f
    Alexandre Oliva authored
    A proprietary embedded operating system that uses clang as its primary
    compiler ships headers that require __clang__ to be defined.  Defining
    that macro causes libstdc++ to adopt workarounds that work for clang
    but that break for GCC.
    
    So, introduce a _GLIBCXX_CLANG macro, and a convention to test for it
    rather than for __clang__, so that a GCC variant that adds -D__clang__
    to satisfy system headers can also -D_GLIBCXX_CLANG=0 to avoid
    workarounds that are not meant for GCC.
    
    I've left fast_float and ryu files alone, their tests for __clang__
    don't seem to be harmful for GCC, they don't include bits/c++config,
    and patching such third-party files would just make trouble for
    updating them without visible benefit.  pstl_config.h, though also
    imported, required adjustment.
    
    
    for  libstdc++-v3/ChangeLog
    
    	* include/bits/c++config (_GLIBCXX_CLANG): Define or undefine.
    	* include/bits/locale_facets_nonio.tcc: Test for it.
    	* include/bits/stl_bvector.h: Likewise.
    	* include/c_compatibility/stdatomic.h: Likewise.
    	* include/experimental/bits/simd.h: Likewise.
    	* include/experimental/bits/simd_builtin.h: Likewise.
    	* include/experimental/bits/simd_detail.h: Likewise.
    	* include/experimental/bits/simd_x86.h: Likewise.
    	* include/experimental/simd: Likewise.
    	* include/std/complex: Likewise.
    	* include/std/ranges: Likewise.
    	* include/std/variant: Likewise.
    	* include/pstl/pstl_config.h: Likewise.
    67be156f
    History
    [libstdc++] add _GLIBCXX_CLANG to workaround predefined __clang__
    Alexandre Oliva authored
    A proprietary embedded operating system that uses clang as its primary
    compiler ships headers that require __clang__ to be defined.  Defining
    that macro causes libstdc++ to adopt workarounds that work for clang
    but that break for GCC.
    
    So, introduce a _GLIBCXX_CLANG macro, and a convention to test for it
    rather than for __clang__, so that a GCC variant that adds -D__clang__
    to satisfy system headers can also -D_GLIBCXX_CLANG=0 to avoid
    workarounds that are not meant for GCC.
    
    I've left fast_float and ryu files alone, their tests for __clang__
    don't seem to be harmful for GCC, they don't include bits/c++config,
    and patching such third-party files would just make trouble for
    updating them without visible benefit.  pstl_config.h, though also
    imported, required adjustment.
    
    
    for  libstdc++-v3/ChangeLog
    
    	* include/bits/c++config (_GLIBCXX_CLANG): Define or undefine.
    	* include/bits/locale_facets_nonio.tcc: Test for it.
    	* include/bits/stl_bvector.h: Likewise.
    	* include/c_compatibility/stdatomic.h: Likewise.
    	* include/experimental/bits/simd.h: Likewise.
    	* include/experimental/bits/simd_builtin.h: Likewise.
    	* include/experimental/bits/simd_detail.h: Likewise.
    	* include/experimental/bits/simd_x86.h: Likewise.
    	* include/experimental/simd: Likewise.
    	* include/std/complex: Likewise.
    	* include/std/ranges: Likewise.
    	* include/std/variant: Likewise.
    	* include/pstl/pstl_config.h: Likewise.