Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

gcc6 error: 'round' is not a member of 'std' (amigaos-m68k) #3342

Closed
glebm opened this issue Mar 12, 2023 · 3 comments · Fixed by #3343
Closed

gcc6 error: 'round' is not a member of 'std' (amigaos-m68k) #3342

glebm opened this issue Mar 12, 2023 · 3 comments · Fixed by #3343

Comments

@glebm
Copy link
Contributor

glebm commented Mar 12, 2023

On master:

In file included from /root/repo/Source/capture.cpp:9:0:
/root/repo/build/_deps/libfmt-src/include/fmt/chrono.h: In function 'void fmt::v9::detail::write_floating_seconds(fmt::v9::memory_buffer&, Duration, int)':
/root/repo/build/_deps/libfmt-src/include/fmt/chrono.h:1174:55: error: 'round' is not a member of 'std'
     if (num_fractional_digits < 6 && static_cast<rep>(std::round(val)) != val)
                                                       ^~~
/root/repo/build/_deps/libfmt-src/include/fmt/chrono.h:1174:55: note: suggested alternative:
In file included from /opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/include/c++/cmath:45:0,
                 from /root/repo/build/_deps/libfmt-src/include/fmt/chrono.h:13,
                 from /root/repo/Source/capture.cpp:9:
/opt/m68k-amigaos/m68k-amigaos/sys-include/math.h:308:25: note:   'round'
 extern __stdargs double round (double);
                         ^~~~~

https://app.circleci.com/pipelines/github/diasurgical/devilutionX/17079/workflows/258308a7-7fff-41f5-ac59-0a50f4d74abf/jobs/108889 (diasurgical/devilutionX#5875)

@glebm
Copy link
Contributor Author

glebm commented Mar 12, 2023

A missing std::round is quite common in older versions of GCC on some platforms.

One way to fix this is to use round instead of std::round.

@glebm
Copy link
Contributor Author

glebm commented Mar 12, 2023

Actually why even round? Is this not just as valid:

-    if (num_fractional_digits < 6 && static_cast<rep>(std::round(val)) != val)
+    if (num_fractional_digits < 6 && num_fractional_digits != 0)
       num_fractional_digits = 6;

I guess the fraction can have more precision than a double, so that it is 0 when converted to a double.

@SappyJoy @phprus @patrickroocks

glebm added a commit to diasurgical/fmt that referenced this issue Mar 12, 2023
On some toolchains, `std::round` is not available.

Fixes fmtlib#3342
@glebm
Copy link
Contributor Author

glebm commented Mar 12, 2023

Example godbolt with another toolchain: https://godbolt.org/z/GfE3MaT15

vitaut pushed a commit that referenced this issue Mar 12, 2023
On some toolchains, `std::round` is not available.

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

Successfully merging a pull request may close this issue.

1 participant