[Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
simark at simark dot ca
sourceware-bugzilla@sourceware.org
Thu Mar 26 17:39:43 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
I noticed that we already include stdlib.h in common-defs.h:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdbsupport/common-defs.h;h=e42d2b80c045361cfa19f52cb146ae32c58f61b3;hb=HEAD#l87
However, according to [1], C++ standard library implementations are not
mandated to make stdlib.h populate the std namespace. I guess your C++ library
doesn't.
[1] https://en.cppreference.com/w/cpp/header
So since we use std::abs, the correct thing to do would indeed be to include
cstdlib. I tried to swap stdlib.h for cstdlib in common-defs.h, I just
stumbled on some old hack in ada-exp.y that can probably be removed. But
otherwise it builds for me.
Can you see if the patch below builds fine for you on macOS?
>From 8ca602f1a6b05cb431b663c8ed0c09537fe31960 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Thu, 26 Mar 2020 13:27:07 -0400
Subject: [PATCH] allo
---
gdb/ada-exp.y | 3 ---
gdbsupport/common-defs.h | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index c5e1e14299e..6e65b212e24 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -720,9 +720,6 @@ primary : '*' primary %prec '.'
static struct obstack temp_parse_space;
-/* The following kludge was found necessary to prevent conflicts between */
-/* defs.h and non-standard stdlib.h files. */
-#define qsort __qsort__dummy
#include "ada-lex.c"
int
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index e42d2b80c04..e1a431c6939 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -84,7 +84,7 @@
#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
--
2.25.1
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list