Skip to content

Commit 27ca26d

Browse files
DimitryAndrictstellar
authored andcommitted
[libc++] Rename __bit_reference template parameter to avoid conflict (llvm#80661)
As of 4d20cfc, `__bit_reference` contains a template `__fill_n` with a bool `_FillValue` parameter. Unfortunately there is a relatively widely used piece of scientific software called NetCDF, which exposes a (C) macro `_FillValue` in its public headers. When building the NetCDF C++ bindings, this quickly leads to compilation errors when the macro interferes with the template in `__bit_reference`. Rename the parameter to `_FillVal` to avoid the conflict. (cherry picked from commit 1ec2522)
1 parent 906220c commit 27ca26d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libcxx/include/__bit_reference

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private:
173173

174174
// fill_n
175175

176-
template <bool _FillValue, class _Cp>
176+
template <bool _FillVal, class _Cp>
177177
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
178178
__fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {
179179
using _It = __bit_iterator<_Cp, false>;
@@ -185,7 +185,7 @@ __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {
185185
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
186186
__storage_type __dn = std::min(__clz_f, __n);
187187
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
188-
if (_FillValue)
188+
if (_FillVal)
189189
*__first.__seg_ |= __m;
190190
else
191191
*__first.__seg_ &= ~__m;
@@ -194,13 +194,13 @@ __fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {
194194
}
195195
// do middle whole words
196196
__storage_type __nw = __n / __bits_per_word;
197-
std::fill_n(std::__to_address(__first.__seg_), __nw, _FillValue ? static_cast<__storage_type>(-1) : 0);
197+
std::fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0);
198198
__n -= __nw * __bits_per_word;
199199
// do last partial word
200200
if (__n > 0) {
201201
__first.__seg_ += __nw;
202202
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
203-
if (_FillValue)
203+
if (_FillVal)
204204
*__first.__seg_ |= __m;
205205
else
206206
*__first.__seg_ &= ~__m;
@@ -1007,7 +1007,7 @@ private:
10071007
friend class __bit_iterator<_Cp, true>;
10081008
template <class _Dp>
10091009
friend struct __bit_array;
1010-
template <bool _FillValue, class _Dp>
1010+
template <bool _FillVal, class _Dp>
10111011
_LIBCPP_CONSTEXPR_SINCE_CXX20 friend void __fill_n(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
10121012

10131013
template <class _Dp, bool _IC>

0 commit comments

Comments
 (0)