[PATCH] dlls: Global variable compatibility update for gcc 10

Michael Cronenworth mike at cchtml.com
Wed Jan 22 21:18:53 CST 2020


https://gcc.gnu.org/gcc-10/porting_to.html#common

Default to -fno-common

A common mistake in C is omitting extern when declaring a global variable
in a header file. If the header is included by several files it results
in multiple definitions of the same variable. In previous GCC versions
this error is ignored. GCC 10 defaults to -fno-common, which means a
linker error will now be reported. To fix this, use extern in header
files when declaring global variables, and ensure each global is defined
in exactly one C file. As a workaround, legacy C code can be compiled
with -fcommon.

      int x;  // tentative definition - avoid in header files

      extern int y;  // correct declaration in a header file

Signed-off-by: Michael Cronenworth <mike at cchtml.com>
---
 dlls/crypt32/crypt32_private.h         |  2 +-
 dlls/dsound/dsound_private.h           |  6 +++---
 dlls/gphoto2.ds/gphoto2_i.h            |  2 +-
 dlls/gphoto2.ds/gphoto2_main.c         |  2 ++
 dlls/mshtml/htmlstyle.h                |  2 +-
 dlls/mshtml/main.c                     |  7 +++++++
 dlls/mshtml/mshtml_private.h           | 12 ++++++------
 dlls/msi/msi.c                         |  2 ++
 dlls/msi/msipriv.h                     |  2 +-
 dlls/sane.ds/sane_i.h                  |  4 ++--
 dlls/sane.ds/sane_main.c               | 17 +++++++++++++++++
 dlls/secur32/secur32_priv.h            |  4 ++--
 dlls/twain_32/twain32_main.c           |  4 +++-
 dlls/twain_32/twain_i.h                |  6 +++---
 dlls/wbemprox/main.c                   |  2 ++
 dlls/wbemprox/wbemprox_private.h       |  4 ++--
 dlls/webservices/webservices_private.h |  6 +++---
 dlls/winebus.sys/bus.h                 |  4 ++--
 dlls/xinput1_3/xinput_private.h        |  4 ++--
 19 files changed, 62 insertions(+), 30 deletions(-)

diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 3d0129e7d4..d92eb1a157 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -152,7 +152,7 @@ BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
  */
 HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID);
 
-HINSTANCE hInstance DECLSPEC_HIDDEN;
+extern HINSTANCE hInstance DECLSPEC_HIDDEN;
 
 void crypt_oid_init(void) DECLSPEC_HIDDEN;
 void crypt_oid_free(void) DECLSPEC_HIDDEN;
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 69c4a2f390..930c3e92ec 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -188,9 +188,9 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
     IDirectSoundBufferImpl **ppdsb,
     IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
 void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
-const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
-const IDirectSound3DBufferVtbl ds3dbvt DECLSPEC_HIDDEN;
-const IKsPropertySetVtbl iksbvt DECLSPEC_HIDDEN;
+extern const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
+extern const IDirectSound3DBufferVtbl ds3dbvt DECLSPEC_HIDDEN;
+extern const IKsPropertySetVtbl iksbvt DECLSPEC_HIDDEN;
 
 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
 
diff --git a/dlls/gphoto2.ds/gphoto2_i.h b/dlls/gphoto2.ds/gphoto2_i.h
index 9ab8bbbf33..6b504821e0 100644
--- a/dlls/gphoto2.ds/gphoto2_i.h
+++ b/dlls/gphoto2.ds/gphoto2_i.h
@@ -100,7 +100,7 @@ struct tagActiveDS
     struct jpeg_decompress_struct	jd;
     struct jpeg_error_mgr		jerr;
 #endif
-} activeDS DECLSPEC_HIDDEN;
+} extern activeDS DECLSPEC_HIDDEN;
 
 /* Helper functions */
 extern TW_UINT16 GPHOTO2_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action) DECLSPEC_HIDDEN;
diff --git a/dlls/gphoto2.ds/gphoto2_main.c b/dlls/gphoto2.ds/gphoto2_main.c
index 28100414cc..4d71c89e2e 100644
--- a/dlls/gphoto2.ds/gphoto2_main.c
+++ b/dlls/gphoto2.ds/gphoto2_main.c
@@ -33,6 +33,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(twain);
 
+struct tagActiveDS activeDS;
+
 DSMENTRYPROC GPHOTO2_dsmentry;
 
 #ifdef HAVE_GPHOTO2
diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h
index 9dcf3d9eed..7a83897043 100644
--- a/dlls/mshtml/htmlstyle.h
+++ b/dlls/mshtml/htmlstyle.h
@@ -142,7 +142,7 @@ void init_css_style(CSSStyle*,nsIDOMCSSStyleDeclaration*,style_qi_t,
                     dispex_static_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
 
 void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode) DECLSPEC_HIDDEN;
-const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl DECLSPEC_HIDDEN;
+extern const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl DECLSPEC_HIDDEN;
 
 HRESULT get_style_property(CSSStyle*,styleid_t,BSTR*) DECLSPEC_HIDDEN;
 HRESULT get_style_property_var(CSSStyle*,styleid_t,VARIANT*) DECLSPEC_HIDDEN;
diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index 29396a5475..e2c927c5f9 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -51,6 +51,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 HINSTANCE hInst;
 DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
 
+void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjCallback*);
+nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*,ExternalCycleCollectionParticipant*);
+nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*);
+void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt);
+void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*);
+void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
+
 static HINSTANCE shdoclc = NULL;
 static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
 static IMultiLanguage2 *mlang;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 9612b32608..cc9eefc528 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -355,12 +355,12 @@ typedef struct {
 
 DEFINE_GUID(IID_nsXPCOMCycleCollectionParticipant, 0x9674489b,0x1f6f,0x4550,0xa7,0x30, 0xcc,0xae,0xdd,0x10,0x4c,0xf9);
 
-nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*) DECLSPEC_HIDDEN;
-nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*,ExternalCycleCollectionParticipant*) DECLSPEC_HIDDEN;
-void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt) DECLSPEC_HIDDEN;
-void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjCallback*) DECLSPEC_HIDDEN;
-void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*) DECLSPEC_HIDDEN;
-void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*) DECLSPEC_HIDDEN;
+extern nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*) DECLSPEC_HIDDEN;
+extern nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*,ExternalCycleCollectionParticipant*) DECLSPEC_HIDDEN;
+extern void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt) DECLSPEC_HIDDEN;
+extern void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjCallback*) DECLSPEC_HIDDEN;
+extern void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*) DECLSPEC_HIDDEN;
+extern void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*) DECLSPEC_HIDDEN;
 
 void init_dispex_with_compat_mode(DispatchEx*,IUnknown*,dispex_static_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
 void release_dispex(DispatchEx*) DECLSPEC_HIDDEN;
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 7bf5004bed..6387b0a937 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -51,6 +51,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
+BOOL is_wow64;
+
 static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
 
 UINT msi_locate_product(LPCWSTR szProduct, MSIINSTALLCONTEXT *context)
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index fca2f9e7b4..6b87cfb3d8 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -42,7 +42,7 @@
 #include "winemsi.h"
 
 static const BOOL is_64bit = sizeof(void *) > sizeof(int);
-BOOL is_wow64 DECLSPEC_HIDDEN;
+extern BOOL is_wow64 DECLSPEC_HIDDEN;
 
 #define MSI_DATASIZEMASK 0x00ff
 #define MSITYPE_VALID    0x0100
diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h
index 941e8b9e1b..d22b1b1723 100644
--- a/dlls/sane.ds/sane_i.h
+++ b/dlls/sane.ds/sane_i.h
@@ -36,7 +36,7 @@
 #include "twain.h"
 
 #ifdef SONAME_LIBSANE
-#define MAKE_FUNCPTR(f) typeof(f) * p##f DECLSPEC_HIDDEN;
+#define MAKE_FUNCPTR(f) extern typeof(f) * p##f DECLSPEC_HIDDEN;
 MAKE_FUNCPTR(sane_init)
 MAKE_FUNCPTR(sane_exit)
 MAKE_FUNCPTR(sane_get_devices)
@@ -84,7 +84,7 @@ struct tagActiveDS
     TW_FIX32            defaultXResolution;
     BOOL                YResolutionSet;
     TW_FIX32            defaultYResolution;
-} activeDS DECLSPEC_HIDDEN;
+} extern activeDS DECLSPEC_HIDDEN;
 
 /* Helper functions */
 extern TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action) DECLSPEC_HIDDEN;
diff --git a/dlls/sane.ds/sane_main.c b/dlls/sane.ds/sane_main.c
index 7af0a2321a..cb9da8e875 100644
--- a/dlls/sane.ds/sane_main.c
+++ b/dlls/sane.ds/sane_main.c
@@ -33,8 +33,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(twain);
 DSMENTRYPROC SANE_dsmentry;
 
 #ifdef SONAME_LIBSANE
+#define MAKE_FUNCPTR(f) typeof(f) * p##f;
+MAKE_FUNCPTR(sane_init)
+MAKE_FUNCPTR(sane_exit)
+MAKE_FUNCPTR(sane_get_devices)
+MAKE_FUNCPTR(sane_open)
+MAKE_FUNCPTR(sane_close)
+MAKE_FUNCPTR(sane_get_option_descriptor)
+MAKE_FUNCPTR(sane_control_option)
+MAKE_FUNCPTR(sane_get_parameters)
+MAKE_FUNCPTR(sane_start)
+MAKE_FUNCPTR(sane_read)
+MAKE_FUNCPTR(sane_cancel)
+MAKE_FUNCPTR(sane_set_io_mode)
+MAKE_FUNCPTR(sane_get_select_fd)
+MAKE_FUNCPTR(sane_strstatus)
+#undef MAKE_FUNCPTR
 
 HINSTANCE SANE_instance;
+struct tagActiveDS activeDS;
 
 static void *libsane_handle;
 
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 5ed26d67ef..1f77955cfd 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -190,8 +190,8 @@ void SECUR32_arc4Cleanup(arc4_info *a4i) DECLSPEC_HIDDEN;
 #define NTLMSSP_NEGOTIATE_56                        0x80000000
 
 
-SecPkgInfoW *ntlm_package_infoW DECLSPEC_HIDDEN;
-SecPkgInfoA *ntlm_package_infoA DECLSPEC_HIDDEN;
+extern SecPkgInfoW *ntlm_package_infoW DECLSPEC_HIDDEN;
+extern SecPkgInfoA *ntlm_package_infoA DECLSPEC_HIDDEN;
 
 /* schannel internal interface */
 typedef struct schan_imp_session_opaque *schan_imp_session;
diff --git a/dlls/twain_32/twain32_main.c b/dlls/twain_32/twain32_main.c
index b1beb96958..0f8ee14430 100644
--- a/dlls/twain_32/twain32_main.c
+++ b/dlls/twain_32/twain32_main.c
@@ -29,7 +29,9 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(twain);
 
-extern HINSTANCE DSM_hinstance;
+TW_UINT16 DSM_twCC;
+activeDS *activeSources;
+HINSTANCE DSM_hinstance;
 
 BOOL WINAPI DllMain (HINSTANCE hinstance, DWORD reason, LPVOID reserved)
 {
diff --git a/dlls/twain_32/twain_i.h b/dlls/twain_32/twain_i.h
index 7939d233bb..ad513458cd 100644
--- a/dlls/twain_32/twain_i.h
+++ b/dlls/twain_32/twain_i.h
@@ -45,11 +45,11 @@ typedef struct tagActiveDS
     HWND                event_window;
 } activeDS;
 
-TW_UINT16 DSM_twCC DECLSPEC_HIDDEN;             /* current condition code of Source Manager */
+extern TW_UINT16 DSM_twCC DECLSPEC_HIDDEN;             /* current condition code of Source Manager */
 
-activeDS *activeSources DECLSPEC_HIDDEN;	/* list of active data sources */
+extern activeDS *activeSources DECLSPEC_HIDDEN;	/* list of active data sources */
 
-HINSTANCE DSM_hinstance DECLSPEC_HIDDEN;
+extern HINSTANCE DSM_hinstance DECLSPEC_HIDDEN;
 
 /* Implementation of operation triplets (From Application to Source Manager) */
 extern TW_UINT16 TWAIN_CloseDS
diff --git a/dlls/wbemprox/main.c b/dlls/wbemprox/main.c
index d90f4f8cc6..0908441498 100644
--- a/dlls/wbemprox/main.c
+++ b/dlls/wbemprox/main.c
@@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
 
 static HINSTANCE instance;
 
+struct list *table_list;
+
 typedef HRESULT (*fnCreateInstance)( LPVOID *ppObj );
 
 typedef struct
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index 9d39a7c92b..9096b392e3 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -20,8 +20,8 @@
 #include "wine/heap.h"
 #include "wine/list.h"
 
-IClientSecurity client_security DECLSPEC_HIDDEN;
-struct list *table_list DECLSPEC_HIDDEN;
+extern IClientSecurity client_security DECLSPEC_HIDDEN;
+extern struct list *table_list DECLSPEC_HIDDEN;
 
 enum param_direction
 {
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index 6f2b90dad2..b352aa52d4 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -18,7 +18,7 @@
 
 #include "winhttp.h"
 
-_locale_t c_locale DECLSPEC_HIDDEN;
+extern _locale_t c_locale DECLSPEC_HIDDEN;
 
 #define STREAM_BUFSIZE 4096
 
@@ -50,8 +50,8 @@ struct dictionary
     ULONG              current_sequence;
     ULONG             *sequence;
 };
-struct dictionary dict_builtin DECLSPEC_HIDDEN;
-const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
+extern struct dictionary dict_builtin DECLSPEC_HIDDEN;
+extern const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
 
 int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
 HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h
index 041a37ad04..22a4b46a51 100644
--- a/dlls/winebus.sys/bus.h
+++ b/dlls/winebus.sys/bus.h
@@ -54,5 +54,5 @@ DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func fu
 DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN;
 BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
 
-HANDLE driver_key DECLSPEC_HIDDEN;
-DEVICE_OBJECT *bus_pdo DECLSPEC_HIDDEN;
+extern HANDLE driver_key DECLSPEC_HIDDEN;
+extern DEVICE_OBJECT *bus_pdo DECLSPEC_HIDDEN;
diff --git a/dlls/xinput1_3/xinput_private.h b/dlls/xinput1_3/xinput_private.h
index f3456cd8e7..9a0e03c1de 100644
--- a/dlls/xinput1_3/xinput_private.h
+++ b/dlls/xinput1_3/xinput_private.h
@@ -26,8 +26,8 @@ typedef struct _xinput_controller
     XINPUT_VIBRATION vibration;
 } xinput_controller;
 
-CRITICAL_SECTION xinput_crit;
-xinput_controller controllers[XUSER_MAX_COUNT];
+extern CRITICAL_SECTION xinput_crit;
+extern xinput_controller controllers[XUSER_MAX_COUNT];
 
 void HID_find_gamepads(xinput_controller *devices) DECLSPEC_HIDDEN;
 void HID_destroy_gamepads(xinput_controller *devices) DECLSPEC_HIDDEN;
-- 
2.24.1




More information about the wine-devel mailing list