p-ranav / indicators

Activity Indicators for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library does not compile.

gogagum opened this issue · comments

After using indicators::ProgressBar class in my code I recieve the following message from gcc-12 compiler:

.../indicators/include/indicators/display_width.hpp:284: error: ‘codecvt_utf8’ is not a member of ‘std’; did you mean ‘codecvt_base’? 
In file included from .../indicators/include/indicators/details/stream_helper.hpp:5, from .../indicators/include/indicators/progress_bar.hpp:5,
.../indicators/include/indicators/display_width.hpp: In function ‘std::wstring unicode::details::utf8_decode(const std::string&)’: 
.../indicators/include/indicators/display_width.hpp:284:29: error: ‘codecvt_utf8’ is not a member of ‘std’; did you mean ‘codecvt_base’? 284 |   std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
commented

Just trying indicators for the first time, ran into same issue. codecvt_utf8 has been deprecated as of C++17. The solution is: "Users should use dedicated text-processing libraries instead." So, it appears the functionality needs to be incorporated into the library.

Another data point: this library doesn't compile on macOS 13 with Apple Clang 14. The reasons are the same; codecvt_utf8 has been removed from the standard library:

In file included from /Users/charles/src/indicators/samples/progress_bar_unicode.cpp:3:
In file included from /Users/charles/src/indicators/include/indicators/indeterminate_progress_bar.hpp:5:
In file included from /Users/charles/src/indicators/include/indicators/details/stream_helper.hpp:5:
/Users/charles/src/indicators/include/indicators/display_width.hpp:284:29: error: no member named 'codecvt_utf8' in namespace 'std'
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                       ~~~~~^
/Users/charles/src/indicators/include/indicators/display_width.hpp:284:49: error: expected '(' for function-style cast or type construction
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                                         ~~~~~~~^
/Users/charles/src/indicators/include/indicators/display_width.hpp:284:50: error: expected unqualified-id
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                                                 ^
/Users/charles/src/indicators/include/indicators/display_width.hpp:285:10: error: use of undeclared identifier 'myconv'
  return myconv.from_bytes(str);
         ^
/Users/charles/src/indicators/include/indicators/display_width.hpp:290:29: error: no member named 'codecvt_utf8' in namespace 'std'
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                       ~~~~~^
/Users/charles/src/indicators/include/indicators/display_width.hpp:290:49: error: expected '(' for function-style cast or type construction
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                                         ~~~~~~~^
/Users/charles/src/indicators/include/indicators/display_width.hpp:290:50: error: expected unqualified-id
  std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
                                                 ^
/Users/charles/src/indicators/include/indicators/display_width.hpp:291:10: error: use of undeclared identifier 'myconv'
  return myconv.to_bytes(str);
commented

Thanks for reporting this issue and thanks for your patience.

I've rewritten the function without codecvt and merged a fix. If the fix does not work, please reopen this issue.

if you confirm that the fix works for you, I'll go ahead and prepare a new release.

commented

@p-ranav I can confirm that building the samples using gcc (GCC) 12.2.1 from f03feac succeeds as opposed to f38bf22.