Use dllimport/dllexport with clang and gcc on Cygwin.

This is required at least for Boost.WinAPI to match the declarations in
Windows SDK headers, which use dllimport.

Also, for clang on Windows, use dllimport/dllexport even beyond Cygwin.
The compiler does support these attributes, and it should for
compatibility with Windows headers.
This commit is contained in:
Andrey Semashev
2018-03-11 17:37:13 +03:00
parent 5ad0730630
commit 3b709bc3ed
2 changed files with 8 additions and 4 deletions

View File

@ -98,11 +98,15 @@
// //
// Dynamic shared object (DSO) and dynamic-link library (DLL) support // Dynamic shared object (DSO) and dynamic-link library (DLL) support
// //
#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
# define BOOST_HAS_DECLSPEC
# define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__))
# define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__))
#else
# define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
# define BOOST_SYMBOL_IMPORT # define BOOST_SYMBOL_IMPORT
# define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
#endif #endif
#define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
// //
// The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through

View File

@ -99,10 +99,10 @@
// Dynamic shared object (DSO) and dynamic-link library (DLL) support // Dynamic shared object (DSO) and dynamic-link library (DLL) support
// //
#if __GNUC__ >= 4 #if __GNUC__ >= 4
# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && !defined(__CYGWIN__) # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
// All Win32 development environments, including 64-bit Windows and MinGW, define // All Win32 development environments, including 64-bit Windows and MinGW, define
// _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment, // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment,
// so does not define _WIN32 or its variants. // so does not define _WIN32 or its variants, but still supports dllexport/dllimport.
# define BOOST_HAS_DECLSPEC # define BOOST_HAS_DECLSPEC
# define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__)) # define BOOST_SYMBOL_EXPORT __attribute__((__dllexport__))
# define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__)) # define BOOST_SYMBOL_IMPORT __attribute__((__dllimport__))