marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.53k stars 146 forks source link

arm64 build error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’? #186

Closed benthetechguy closed 1 year ago

benthetechguy commented 1 year ago

Environment

toml++ version and/or commit hash: Version 3.2.0 with backported commits https://github.com/marzer/tomlplusplus/commit/c8780a5b8e8d2f8ff1fd747a3a89b7becebfdee9 and https://github.com/marzer/tomlplusplus/commit/0a90913abf9390b9e08ab6d3b40ac11634553f38

Compiler:
gcc 12.2.0

C++ standard mode:
17

Target arch:
aarch64

Library configuration overrides:
None

Relevant compilation flags: -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/pybind11/include -I/usr/include/python3.11 -c src/encoding_decoding.cpp -o build/temp.linux-arm64-cpython-311/src/encoding_decoding.o -std=c++17

Describe the bug

I am packaging pytomlpp for Debian. It depends on @Tachi107's tomlplusplus package, which does nothing special except adding the two Float16 commits made after the last release. When I try to build the pytomlpp package on arm64, I get the error

In file included from /usr/include/toml++/toml.h:39,
                 from include/pytomlpp/pytomlpp.hpp:31,
                 from src/encoding_decoding.cpp:1:
/usr/include/toml++/impl/forward_declarations.h:630:29: error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’?
  630 |         struct float_traits<_Float16> : float_traits_base<_Float16, __FLT16_MANT_DIG__, __FLT16_DIG__>
      |                             ^~~~~~~~
      |                             _Float64

in a few different places. My current packaging of pytomlpp is available here if that would help.

marzer commented 1 year ago

Does it work if you explicitly set -DTOML_ENABLE_FLOAT16=0?

The default for this is "use the compiler settings", but that has proven to be very difficult to detect in a reliable way (compiler bugs etc.). I will probably make 0 the default in a future version.

benthetechguy commented 1 year ago

Yes, it works if I set that option.

marzer commented 1 year ago

Ah excellent.

marzer commented 1 year ago

@benthetechguy I have pulled the trigger on this and removed all the 'automagic' _Float16 detection nonsense, so as of d8bb717 this should no longer be an issue. Thanks for the report!