cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

Build error with C++20 standard #674

Open AStepaniuk opened 1 year ago

AStepaniuk commented 1 year ago

When I'm trying to enable С++ 20 standard (using gcc 9.5 on ubuntu) I'm getting build error similar to the one mentioned at #498 .

I think, it is caused by the change in C++20 filesystem lib: https://en.cppreference.com/w/cpp/filesystem/path/string

std::string u8string() const; | (since C++17)(until C++20) std::u8string u8string() const; | (since C++20)

In turn, std::u8string is declared as: std::basic_string<char8_t> , which is incompatible with std::string.

A short-term fix: Switching to C++17 eliminates the build error.

As a long-term fix, maybe it worth to use std::filesystem::path::string() method instead of ...u8string()?
In the current master branch there is at least one place, where u8string() is used: https://github.com/cnjinhao/nana/blob/master/source/detail/posix/xdnd_protocol.hpp#L159

According to https://en.cppreference.com/w/cpp/filesystem/path/string using string() should be safe for POSIX:

If path::value_type is char, conversion, if any, is system-dependent. This is the case on typical POSIX systems (such as Linux), where native encoding is UTF-8 and string() performs no conversion.