Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build error with C++20 standard #674

Open
AStepaniuk opened this issue May 20, 2023 · 0 comments
Open

Build error with C++20 standard #674

AStepaniuk opened this issue May 20, 2023 · 0 comments

Comments

@AStepaniuk
Copy link

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant