Created attachment 182374 [details] Fix min/max macro usage in devel/gdb I have been experimenting with a newer version of libc++ in the projects/clang500-import branch, and it turns out that gdb has traditionally defined their own min/max macros. However, it compiles most of its .c files as C++, and min/max macros are not compatible with C++. Due to a slightly different include order in newer versions of libc++, this now even leads to compilation errors like the following: In file included from doublest.c:30: In file included from build-gnulib/import/math.h:27: In file included from /usr/include/c++/v1/math.h:310: In file included from /usr/include/c++/v1/limits:112: /usr/include/c++/v1/__undef_min_max:17:2: warning: : macro min is incompatible with C++. #undefing min [-W#warnings] #warning: macro min is incompatible with C++. #undefing min ^ /usr/include/c++/v1/__undef_min_max:29:2: warning: : macro max is incompatible with C++. #undefing max [-W#warnings] #warning: macro max is incompatible with C++. #undefing max ^ c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] doublest.c:258:19: error: use of undeclared identifier 'min'; did you mean 'fmin'? mant_bits = min (mant_bits_left, 32); ^~~ fmin /usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT ^ doublest.c:568:19: error: use of undeclared identifier 'min'; did you mean 'fmin'? mant_bits = min (mant_bits_left, 32); ^~~ fmin /usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT ^ doublest.c:912:25: error: use of undeclared identifier 'min'; did you mean 'fmin'? memcpy (to, from, min (TYPE_LENGTH (from_type), TYPE_LENGTH (to_type))); ^~~ fmin /usr/include/c++/v1/math.h:1221:1: note: 'fmin' declared here fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT ^ 2 warnings and 3 errors generated. Upstream has also seen this problem with newer versions of GNU libstdc++, so it made the following two commits: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=325fac504a327de9c46a4e5cf9c88ece9d9d7701 ("gdb: Use std::min and std::max throughout") https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=768adc05c44c7e8b5c0f9ca5ad3ca96657715293 ("gdb: Fix std::{min, max}-related build breakage on 32-bit hosts") Here is a patch to add these two commits to our devel/gdb port. I hope they will no longer be necessary when a new gdb version is released.
Testing it. Soon a feedback will follow thanks!
Is this still relevant?
I guess, I've lost this PR when I changed account. Really sorry. I can close it. We're currently working on gdb 8.1, which already includes those patches.