fpclassify namespace specification breaks build on NetBSD
Version
24.7.0
Platform
Subsystem
No response
What steps will reproduce the bug?
When building nodejs 24.7.0 on NetBSD, I see:
In file included from ../deps/v8/include/v8-platform.h:8,
from ../src/tracing/traced_value.h:8,
from ../src/tracing/traced_value.cc:5:
../src/tracing/traced_value.cc: In function 'std::string node::tracing::{anonymous}::DoubleToCString(double)':
../src/tracing/traced_value.cc:90:33: error: expected unqualified-id before '(' token
90 | switch (FPCLASSIFY_NAMESPACE::fpclassify(v)) {
| ^~~~~~~~~~
The problem is that fpclassify is a macro in math.h:
#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
I use this patch as a workaround:
--- src/tracing/traced_value.cc.orig 2025-09-01 20:45:44.230556337 +0000
+++ src/tracing/traced_value.cc
@@ -87,7 +87,11 @@ std::string EscapeString(const char* val
}
std::string DoubleToCString(double v) {
+#if defined(__NetBSD__)
+ switch (fpclassify(v)) {
+#else
switch (FPCLASSIFY_NAMESPACE::fpclassify(v)) {
+#endif
case FP_NAN: return "\"NaN\"";
case FP_INFINITE: return (v < 0.0 ? "\"-Infinity\"" : "\"Infinity\"");
case FP_ZERO: return "0";
Adding || defined(NetBSD) to the FPCLASSIFY_NAMESPACE definition block at the top doesn't work because then it's still ::fpclassify which won't work with the macro.
If this is not allowed to be a macro and I should file a bug report with NetBSD, please let me know.
Thanks!
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
see above
What do you see instead?
see above
Additional information
No response