texus / TGUI

Cross-platform modern c++ GUI

Home Page:https://tgui.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows Build Issue

Jim-Marsden opened this issue · comments

When I was building on windows, it was complaining about std::from_chars in String.cpp. I had the same issue with clang and msvc.

I put #include <charconv> in String.hpp and it resolved my issue.

I had no issue on Linux.

Which include did you add? charconv?
Which TGUI version are you using, 0.8 or 0.9-dev?
Are you specifying c++17 or c++20 in your project settings (as Visual Studio by default probably wouldn't try to use that code)?
I'm surprised that the compiler defined __cpp_lib_to_chars without the charconv or version header being included.

I'm sorry, yeah I included charconv, I am using TGUI 0.9. I'm using C++20.

Admittedly, I'm being strange with how I'm doing things, but I'm using CMake on windows, and using git modules.

Ok. I've fixed the issue now.
When TGUI is compiled you can set the TGUI_CXX_STANDARD option in CMake to let it use newer functions. The charconv header was only being included when TGUI_CXX_STANDARD was 17 or 20, while the from_chars code was being compiled even with TGUI_CXX_STANDARD set to 14 (which is the default).

If you leave TGUI on the default of c++14 then it won't try to use from_chars anymore. You could set TGUI_CXX_STANDARD to a higher version to enable some newer code, but (except for this bug) it will work fine to use TGUI in c++14 mode while your project uses c++20.

After I wrote my reply I noticed that you did write "charconv" in your first message (by pressing "edit" on the message), but github parses those quotes as html so it doesn't display it if you don't put backticks around it.