Hi,
When building the Cygwin DLL, linking fails if the Win32 functions
have been declared with DECLSPEC_IMPORT. With the old w32api headers
this was handled by a __W32API_USE_DLLIMPORT__ definition in winbase.h
and other headers. This is obviously not defined when building Cygwin.
However, I didn't want to enforce w32api-isms on Mingw64 headers, so I
looked for another solution. Apparently, many SDK headers have guarded
the DECLSPEC_IMPORT stuff along the lines of the upstream headers, but
some of them are missing the required guard. The below patch applies
them as needed.
The downside of not having __W32API_USE_DLLIMPORT__ is that Cygwin now
has to do something like this:
#define _ADVAPI32_
#define _DSGETDCAPI_
#define _GDI32_
#define _KERNEL32_
#define _OLE32_
#define _SHELL32_
#define _SPOOL32_
#define _USER32_
#define _WINMM_
#define WINIMPM
#define WINSOCK_API_LINKAGE
which looks kind of awkward. I'm ok to keep it that way, but maybe
somebody has a neat idea how to simplify this within the MIngw64 SDK
headers?
Other than that, ok to apply?
Thanks,
Corinna
* winbase.h (ZAWPROXYAPI): Define as empty if _ZAWPROXY_ is defined.
* objbase.h (WINOLEAPI): Define as empty if _OLE32_ is defined.
WINOLEAPI_: Ditto.
* winnt.h (NTSYSAPI): Define as empty if _NTSYSTEM_ is defined.
(NTSYSCALLAPI): Ditto.
* winuser.h (WINUSERAPI): Define as empty if _USER32_ is defined.
* wingdi.h (WINSPOOLAPI): Define as empty if _SPOOL32_ is defined.
Index: winbase.h
===================================================================
--- winbase.h (revision 5167)
+++ winbase.h (working copy)
@@ -24,7 +24,11 @@
#endif
#endif
+#ifndef _ZAWPROXY_
#define ZAWPROXYAPI DECLSPEC_IMPORT
+#else
+#define ZAWPROXYAPI
+#endif
#ifdef __cplusplus
extern "C" {
Index: objbase.h
===================================================================
--- objbase.h (revision 5167)
+++ objbase.h (working copy)
@@ -11,8 +11,13 @@
#include <pshpack8.h>
+#ifdef _OLE32_
+#define WINOLEAPI EXTERN_C HRESULT WINAPI
+#define WINOLEAPI_(type) EXTERN_C type WINAPI
+#else
#define WINOLEAPI EXTERN_C DECLSPEC_IMPORT HRESULT WINAPI
#define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT type WINAPI
+#endif
#if defined(__cplusplus) && !defined(CINTERFACE)
Index: winnt.h
===================================================================
--- winnt.h (revision 5173)
+++ winnt.h (working copy)
@@ -175,8 +175,13 @@
#define FASTCALL
#endif
#define NTAPI __stdcall
+#if !defined(_NTSYSTEM_)
#define NTSYSAPI DECLSPEC_IMPORT
#define NTSYSCALLAPI DECLSPEC_IMPORT
+#else
+#define NTSYSAPI
+#define NTSYSCALLAPI
+#endif
#ifndef VOID
#define VOID void
Index: winuser.h
===================================================================
--- winuser.h (revision 5167)
+++ winuser.h (working copy)
@@ -8,7 +8,11 @@
#include <_mingw_unicode.h>
+#ifdef _USER32_
+#define WINUSERAPI
+#else
#define WINUSERAPI DECLSPEC_IMPORT
+#endif
#ifdef __cplusplus
extern "C" {
Index: wingdi.h
===================================================================
--- wingdi.h (revision 5167)
+++ wingdi.h (working copy)
@@ -14,7 +14,11 @@
#define WINGDIAPI DECLSPEC_IMPORT
#endif
+#ifdef _SPOOL32_
+#define WINSPOOLAPI
+#else
#define WINSPOOLAPI DECLSPEC_IMPORT
+#endif
#ifdef __cplusplus
extern "C" {
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public