karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3, IMAP protocols. It is based on the standard C++ 17 and Boost library.
Other
382 stars 102 forks source link

Examples fail to compile in C++20 mode #78

Closed sabelka closed 3 years ago

sabelka commented 3 years ago

I know mailio uses CMAKE_CXX_STANDARD=17 but when I try to experiment with C++20 I get errors like the following when compiling the examples.

/home/rainer/src/mailio/examples/smtp_utf8_qp_msg.cpp:46:64: error: no matching function for call to ‘mailio::message::subject(const char8_t [52])’ 46 | msg.subject(u8"smtp utf8 quoted printable поÑÑка");

The problem is, that the type of u8 string literals changed in C++20 from char to char8_t.

Adding u8string overloads to mailio::message::subject(const string&) and mailio::mime::content(const string&) would fix this error. Other possibilities how to handle this incompatibility between c++17 and 20 are proposed here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html

What do you think?

karastojko commented 3 years ago

Thanks for pointing out this issue. I am considering the reinterpret_cast as the quickest solution, but I'll play a little bit with other approaches. What I have also discovered is that VS2019 and Gcc work differently with UTF-8 on Windows. Seems that VS requires the C++ file to be UTF-8 encoded with BOM to work properly.

karastojko commented 3 years ago

Fixed with the latest commit.