tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

[C++20] Failed to build with error C2440: 'initializing': cannot convert from 'const char8_t [4]' to 'const td::Slice' #2567

Closed Od0VxibTqto6Hs closed 11 months ago

Od0VxibTqto6Hs commented 1 year ago

Summary

Tdlib failed to build with error C2440: 'initializing': cannot convert from 'const char8_t [4]' to 'const td::Slice' on /std:c++20 option.

In C++20 u8 string literals are based on the char8_t type.

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0482r6.html https://learn.microsoft.com/en-us/cpp/build/reference/zc-char8-t?view=msvc-170

Additional Option

set _CL_=/std:c++20

Error Info

emoji.cpp
tdutils\td\utils\emoji.cpp(188): error C2440: 'initializing': cannot convert from 'const char8_t [4]' to 'const td::Slice'
tdutils\td\utils\emoji.cpp(188): note: 'td::Slice::Slice': no overloaded function could convert all the argument types
tdutils\td/utils/Slice.h(153): note: could be 'td::Slice::Slice(const td::string &)'
tdutils\td\utils\emoji.cpp(188): note: 'td::Slice::Slice(const td::string &)': cannot convert argument 1 from 'const char8_t [4]' to 'const td::string &'
tdutils\td\utils\emoji.cpp(188): note: Reason: cannot convert from 'const char8_t [4]' to 'const td::string'

Related Code

https://github.com/tdlib/td/blob/a7f8ff6eefbb4951d62b9e29bc4f7b95a28a46f0/tdutils/td/utils/emoji.cpp#L188-L195

levlam commented 1 year ago

TDLib has multiple incompatibilities with C++20 and currently is supposed to be built with a C++14 compiler as specified in CMakeLists.txt.

levlam commented 1 year ago

C++20 doesn't have anymore a simple way to create UTF-8 encoded strings using character codes, so there is no good way to write this code in C++20.

Od0VxibTqto6Hs commented 1 year ago

TDLib has multiple incompatibilities with C++20 and currently is supposed to be built with a C++14 compiler as specified in CMakeLists.txt.

Thanks for your reply and provide the information.