kokkos / mdspan

Reference implementation of mdspan targeting C++23
Other
401 stars 66 forks source link

Avoid reserved identifier collisions with newlib #281

Closed ehntoo closed 1 year ago

ehntoo commented 1 year ago

Newlib defines a macro _U in ctype.h (https://github.com/bminor/newlib/blob/048031501043e61ca31713b92ce2190213c7fb21/newlib/libc/include/ctype.h#L60-L67), resulting in a collision with the existing template names for compressed_pair. Use _T1 and _T2 instead of _T and _U to avoid this collision. _T1 and _T2 are already used elsewhere, for example in type_list.hpp (https://github.com/kokkos/mdspan/blob/9d0a451e11177cbdeaef035c7914b0aa73ddd1e2/include/experimental/p0009_bits/type_list.hpp#L76), so their use here should hopefully not introduce any new collisions with other environments.

Fixes #187.

Readme example compiler explorer demonstrating the original issue: https://godbolt.org/z/s6qzafWP4

And a successful build made with this patch: https://godbolt.org/z/zbMf4hddj

mhoemmen commented 1 year ago

This should fix https://github.com/kokkos/mdspan/issues/187 , from what I understand. Thanks for contributing! : - )