p-ranav / indicators

Activity Indicators for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

c++17 deprecated codecvt_utf8 and not work on windows release build

zhongsiz opened this issue · comments

os: win10 x64
compiler: vs2019 msvc compile with c++17
install with vcpkg:

Computing installation plan...
The following packages are already installed:
    indicators[core]:x64-windows -> 2020-10-30
Package indicators:x64-windows is already installed

Total elapsed time: 13.8 us

The package indicators:x64-windows provides CMake targets:

find_package(indicators CONFIG REQUIRED)
target_link_libraries(main PRIVATE indicators::indicators)

generate compiler errors:

D:\libs\vcpkg\installed\x64-windows\include\indicators/display_width.hpp(281): error C2220: the following warning is t reated as an error D:\libs\vcpkg\installed\x64-windows\include\indicators/display_width.hpp(281): warning C4996: 'std::codecvt_utf8<wchar _t,1114111,0>': warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std: :codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std:: codecvt class template is NOT deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; c onsider using MultiByteToWideChar() and WideCharToMultiByte() from <Windows.h> instead. You can define _SILENCE_CXX17_ CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

also when skip this warnning, release(RelWithDbg) build is not work(debug is ok). here is the call stack:

// my code
bars[idx].set_option(option::PrefixText{"600000.SH"});

// exit with call stack
KernelBase.dll!00007ffb4e34a839()	Unknown
vcruntime140.dll!00007ffb3e924880()	Unknown
FalconTool.exe!std::_Throw_range_error(const char * const _Message) Line 207	C++ 
FalconTool.exe!std::wstring_convert<std::codecvt_utf8<wchar_t,1114111,0>,wchar_t,    std::allocator<wchar_t>,std::allocator<char>>::from_bytes(const char * _First, const char * _Last)     Line 400	C++
[Inline Frame] FalconTool.exe!std::wstring_convert<std::codecvt_utf8<wchar_t,1114111,0>,wchar_t,    std::allocator<wchar_t>,std::allocator<char>>::from_bytes(const std::string &) Line 354	C++
FalconTool.exe!unicode::details::utf8_decode(const std::string & str) Line 282	C++
FalconTool.exe!unicode::display_width(const std::string & input) Line 295	C++
FalconTool.exe!indicators::ProgressBar::get_prefix_text() Line 222	C++
FalconTool.exe!indicators::ProgressBar::print_progress(bool from_multi_progress) Line 311	C++
FalconTool.exe!indicators::DynamicProgress<indicators::ProgressBar>::print_progress() Line 105	C++
[Inline Frame] FalconTool.exe!indicators::DynamicProgress<indicators::ProgressBar>::operator[](unsigned __int64) Line 28	C++