Closed 0-wiz-0 closed 3 weeks ago
The title of this issue is factually incorrect – lround
is a member of namespace std
(round and return long int
, overloaded for standard floating point types): https://en.cppreference.com/w/cpp/numeric/math/round
This is implemented correctly in GNU libstdc++ and llvm libc++. The patch is not correct.
You mentioned using NetBSD. Is this with pkgsrc gcc or native GCC? Please take it to the maintainers of those repositories to solve this issue.
I reported this to a NetBSD mailing list, and the following test program works fine:
#include <cmath>
int main(int argc, char **argv)
{
long double v = 1.7;
auto a = std::lround(v);
return a;
}
However, when cmath
is not included, I get:
i.cc: In function ‘int main(int, char**)’:
i.cc:5:23: error: ‘lround’ is not a member of ‘std’
5 | auto a = std::lround(v);
| ^~~~~~
I'm currently testing this patch instead:
--- src/osd/modules/input/input_sdl.cpp.orig 2024-05-29 17:42:54.000000000 +0000
+++ src/osd/modules/input/input_sdl.cpp
@@ -31,6 +31,7 @@
#include <SDL2/SDL.h>
#include <algorithm>
+#include <cmath>
#include <cctype>
#include <chrono>
#include <cstddef>
and will let you know when the compilation finishes.
Yes, adding that header fixes the build for me, and https://en.cppreference.com/w/cpp/numeric/math/round that you cited says you should include that - please add it! Thanks.
Thanks, this has been added in https://github.com/mamedev/mame/commit/c49f62b4b34e819e27e635d5a2edf07dbed888ad
MAME version
0.266
System information
NetBSD 10.99.10/amd64 gcc 10.5.0
INI configuration details
Emulated system/software
n/a
Incorrect behaviour
The build of mame fails with:
Expected behaviour
Build succeeds.
Steps to reproduce
Build mame on NetBSD.
Additional details
I use this patch to work around this problem - please let me know if it's not the correct solution: