-#undef NCURSES_API
-#undef NCURSES_CXX_IMPEXP
-#undef NCURSES_EXPORT
-#undef NCURSES_EXPORT_VAR
-#undef NCURSES_IMPEXP
-
-#if defined(__CYGWIN__) || defined(_WIN32)
-# if defined(NCURSES_DLL)
-# if defined(NCURSES_STATIC)
-# undef NCURSES_STATIC
-# endif
-# endif
-# if defined(NCURSES_DLL)
-/* building a DLL */
-# define NCURSES_IMPEXP __declspec(dllexport)
-# elif defined(NCURSES_STATIC)
-/* building or linking to a static library */
-# define NCURSES_IMPEXP /* nothing */
-# else
-/* linking to the DLL */
-# define NCURSES_IMPEXP __declspec(dllimport)
-# endif
-# define NCURSES_API __cdecl
-# define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
-#endif
-
-/* Take care of non-Windows platforms */
-#if !defined(NCURSES_IMPEXP)
-# define NCURSES_IMPEXP @NCURSES_IMPEXP@
-#endif
-#if !defined(NCURSES_CXX_IMPEXP)
-# define NCURSES_CXX_IMPEXP @NCURSES_CXX_IMPEXP@
-#endif
-#if !defined(NCURSES_API)
-# define NCURSES_API /* nothing */
-#endif
-#if !defined(NCURSES_EXPORT)
-# define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-#endif
-#if !defined(NCURSES_EXPORT_VAR)
-# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
+#if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64))
+# if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */
+# define NCURSES_EXPORT_GENERAL_IMPORT
+# define NCURSES_EXPORT_GENERAL_EXPORT
+# else
+# define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport)
+# define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport)
+# endif
+# define NCURSES_API __cdecl
+#else
+# define NCURSES_EXPORT_GENERAL_IMPORT
+# if (__GNUC__ >= 4) && !defined(__cplusplus)
+# define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility ("default")))
+# else
+# define NCURSES_EXPORT_GENERAL_EXPORT
+# endif
+# define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */