-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codecvt_utf8 removed in C++26 #1098
Comments
Seems like at least there are two defines: (Also worth noting that I didn't have to do that on GCC 14 with C++26) |
I've worked around it like so:
|
Based on the anticipated standard for C++26, it seems like the appropriate thing to do is set CLI11_HAS_CODECVT=0 if we are in C++26, as that function call is deprecated due to it not meeting current unicode standards, so might not work right anyway. |
hmmm I am not getting a clang19 c++26 test to fail like indicated. in #1100. I made some potential modifications in macros.hpp. Would it be possible to try those modifications (uncomment them) in your setup. Also can you provide more details on your setup to see if it can be replicated in a CI build job? |
@phlptp . cd CLI11
git checkout main && git pull
mkdir -p ../build-CLI11 && cd ../build-CLI11
export CC="/opt/homebrew/opt/llvm@19/bin/clang"
export CXX="/opt/homebrew/opt/llvm@19/bin/clang++"
export CPPFLAGS="-I/opt/homebrew/opt/llvm@19/include"
export LDFLAGS="-L/opt/homebrew/opt/llvm@19/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@19/lib/c++"
cmake -G Ninja -DCMAKE_CXX_STANDARD=26 -DCMAKE_CXX_EXTENSIONS:BOOL=OFF -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=ON -DCMAKE_CXX_FLAGS_INIT:STRING="-stdlib=libc++" ../CLI11
ninja [ 50%][116/228] Building CXX object tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o
FAILED: tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o
/opt/homebrew/opt/llvm@19/bin/clang++ -I/Users/julien/Software/Others/CLI11/include -stdlib=libc++ -std=c++26 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=12.1 -MD -MT tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o -MF tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o.d @tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o.modmap -o tests/CMakeFiles/ensure_utf8.dir/applications/ensure_utf8.cpp.o -c /Users/julien/Software/Others/CLI11/tests/applications/ensure_utf8.cpp
In file included from /Users/julien/Software/Others/CLI11/tests/applications/ensure_utf8.cpp:7:
In file included from /Users/julien/Software/Others/CLI11/include/CLI/CLI.hpp:18:
In file included from /Users/julien/Software/Others/CLI11/include/CLI/Encoding.hpp:54:
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:68:17: error: no member named 'wstring_convert' in namespace 'std'
68 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(str, str + str_size);
| ~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:68:38: error: no member named 'codecvt_utf8' in namespace 'std'
68 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(str, str + str_size);
| ~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:68:58: error: expected '(' for function-style cast or type construction
68 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(str, str + str_size);
| ~~~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:68:61: error: expected expression
68 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(str, str + str_size);
| ^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:99:17: error: no member named 'wstring_convert' in namespace 'std'
99 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(str, str + str_size);
| ~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:99:38: error: no member named 'codecvt_utf8' in namespace 'std'
99 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(str, str + str_size);
| ~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:99:58: error: expected '(' for function-style cast or type construction
99 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(str, str + str_size);
| ~~~~~~~^
/Users/julien/Software/Others/CLI11/include/CLI/impl/Encoding_inl.hpp:99:61: error: expected expression
99 | return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(str, str + str_size);
| ^
8 errors generated. System info: This is an M1 Max.
|
I checked out 464306b from #1100 (before you commented the macros out). I get a different build error
|
I will keep trying, thanks |
as best as I can tell that second compiler error is some other change in llvm 19. That seems specific to M1 Macs. I don't have access to that platform and don't know how to replicate on a CI system. Going to need some help from someone who can get into the templates and has access to the specific platform to help debug. |
@phlptp see this compiler explorer: https://godbolt.org/z/Toes7rhM9 I took the single include CLI11.hpp from e43ff02, and recreated the test in main. The key is passing |
I reduced it down to a 240 lines example https://godbolt.org/z/jroxPcxbr , the error is more informative and says
Which I can indeed reproduce with the full CLI11.hpp and just putting this
|
Ok, so the difference is that #include <complex>
#include <type_traits>
// Check for tuple like types, as in classes with a tuple_size type trait
template <typename S>
class is_tuple_like {
template <typename SS>
// static auto test(int)
// -> decltype(std::conditional<(std::tuple_size<SS>::value > 0),
// std::true_type, std::false_type>::type());
static auto test(int)
-> decltype(std::tuple_size<typename std::decay<SS>::type>::value,
std::true_type{});
template <typename>
static auto test(...) -> std::false_type;
public:
static constexpr bool value = decltype(test<S>(0))::value;
};
int main() {
static_assert(!is_tuple_like<std::complex<double>>::value);
} |
Ok found it: https://en.cppreference.com/w/cpp/utility/tuple_size https://en.cppreference.com/w/cpp/numeric/complex/tuple_size It was added by P2819R2 : https://wg21.link/P2819R2 |
This is not specific to M1 macs. It is specific to the change being bleeding edge C++26, and it was only implemented in LLVM's libc++. Compiler explorer clang compilers are on linux, and even the x86-64 19.1.0 will produce the error (cf https://godbolt.org/z/E1dqKPaoj ) That being said, just FYI if you want to run something on apple silicon, you can use github actions with the "macos-14" or "macos-15" runners which are M1s. |
* Modifies #1100 * That PR comes from https://github.com/phlptp/CLI11 and unfortunately I have no way of opening a PR to that repo, pointing to that branch... The commit you care about is 9a2884a @phlptp where I fix the build error on LLVM 19 with C++26 after rooting the actual template issue (see #1098 (comment)) It comes down to C++26 adding a tuple interface to std::complex https://en.cppreference.com/w/cpp/numeric/complex/tuple_size --------- Co-authored-by: Philip Top <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
CLI11/include/CLI/Macros.hpp
Lines 98 to 104 in 063b2c9
Using llvm 19, in C++26 mode, can't compile
The text was updated successfully, but these errors were encountered: