ttsuki/nanojson

Low compiler compatibility due to to_chars / Elementary string conversions (+ floating point)

comment-out opened this issue · 3 comments

https://en.cppreference.com/w/cpp/compiler_support/17
Compiler support for the Elementary string conversions* feature is currently limited to gcc 11 and MSVC 19.24.
I'm unable to compile nanojson2 with Debian 11's clang and gcc packages.
gcc 11 is not available in Debian 11.

The Debian 11 Hard Freeze was on 2021-03-12, which happens to be in between the release of clang-11 and gcc-11

$ cat /etc/debian_version
11.3

$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110

$ clang++-11 --version
Debian clang version 11.0.1-2

Thank you for opening issue.

Yes, currently, nanojson2 needs an STL that fully supports P0067R5 (to_chars/from_chars with FP), e.g. libstdc++-11.

I've been considering a fallback implementation using std::stringstream, but not implemented yet.

Please try #3.

Thanks, it compiles and runs successfully with gcc and clang.
Here is the sample binary output (matches on both compilers)
example_output.txt

Additionally, here's a .gitignore diff for ignoring CMake files.

diff --git a/.gitignore b/.gitignore
index 8ae252a..df87500 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,11 @@
 /.vs
 /out
+
+# cmake
+CMakeCache.txt
+CMakeFiles/
+cmake_install.cmake
+Makefile
+
+# sample binary
+nanojson2