From 3b7be02480bbc462f2ebdd0eff156675dd57c50a Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 20 Mar 2018 11:39:28 -0400 Subject: ccmake: Fix compilation with ncurses on Solaris On Solaris the ncurses header may define an `__attribute__` macro. This breaks C++ headers that use `__attribute__(...)` syntax. Somehow it causes references to unresolved symbols: __gthrw_pthread_once __gthrw_pthread_mutex_lock __gthrw_pthread_mutex_unlock instead of references to the correct symbols: pthread_once pthread_mutex_lock pthread_mutex_unlock Detect this case and undefine the `__attribute__` macro after including the curses headers. --- Source/CursesDialog/cmCursesStandardIncludes.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h index 332d2af..60bad94 100644 --- a/Source/CursesDialog/cmCursesStandardIncludes.h +++ b/Source/CursesDialog/cmCursesStandardIncludes.h @@ -5,6 +5,11 @@ #include "cmConfigure.h" // IWYU pragma: keep +// Record whether __attribute__ is currently defined. See purpose below. +#ifndef __attribute__ +#define cm_no__attribute__ +#endif + #if defined(__hpux) #define _BOOL_DEFINED #include @@ -29,4 +34,12 @@ inline void curses_clear() #undef erase #undef clear +// The curses headers on some platforms (e.g. Solaris) may +// define __attribute__ as a macro. This breaks C++ headers +// in some cases, so undefine it now. +#if defined(cm_no__attribute__) && defined(__attribute__) +#undef __attribute__ +#endif +#undef cm_no__attribute__ + #endif // cmCursesStandardIncludes_h -- cgit v0.12