[libc-commits] [libc] [llvm] [libc] Templatize strtointeger implementation. (PR #165884)

Louis Dionne via libc-commits libc-commits at lists.llvm.org
Mon Dec 1 06:36:48 PST 2025


ldionne wrote:

We started seeing failures in some of our downstream builds since this patch landed. The cause seems to be that `libc/src/__support/str_to_integer.h` is now including the `src/__support/wctype_utils.h` header, which does:

```
libc/src/__support/wctype_utils.h:43:44: error: unknown type name 'wint_t'
   43 | LIBC_INLINE static constexpr bool iswlower(wint_t wch) {
      |                                            ^
```

This is happening in a build where the underlying C library does not provide support for wide characters (which is represented in libc++ by `#if _LIBCPP_HAS_WIDE_CHARACTERS`). This was not noticed by our upstream CI since it does not actually build against a C library that doesn't provide the wchar-related declarations: it merely turns off the associated libc++ interfaces.

This actually brings up an interesting and important question. Since libc++ supports various "carve outs" like `_LIBCPP_HAS_WIDE_CHARACTERS`, `_LIBCPP_HAS_LOCALIZATION`, etc, and since libc++ now uses libc as an implementation detail for some of its functionality, there's kind of a requirement for libc to support the same carve outs. I don't know whether that's desirable and I think we should think about the overall problem to avoid issues like this in the future, since I don't really think it makes sense to ask libc to start supporting all the same carve outs that libc++ has (and in exactly the same way), and to add this coupling between both projects.

TBH, I don't really have a good suggestion to fix this breakage at the moment. Conditionalizing the include of `src/__support/wctype_utils.h` and using `#if _LIBCPP_HAS_WIDE_CHARACTERS` around the `if constexpr` (to avoid mentioning e.g. `internal::iswspace` which might not exist) would technically solve the problem, but I don't want to ask libc to do that since it's a poor way to address the issue.

https://github.com/llvm/llvm-project/pull/165884


More information about the libc-commits mailing list