From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master cc5325b: Pacify -Wcast-function-type warnings in GCC 8.1 Date: Mon, 20 Aug 2018 15:18:40 +0100 Message-ID: References: <20180817143134.25638.77810@vcs0.savannah.gnu.org> <20180817143136.6E89A209C7@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1534775588 14116 195.159.176.226 (20 Aug 2018 14:33:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2018 14:33:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 20 16:33:04 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frlEr-0003VD-QF for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 16:33:02 +0200 Original-Received: from localhost ([::1]:47447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frlGy-0006gt-Dq for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 10:35:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frl1B-0001OB-2s for emacs-devel@gnu.org; Mon, 20 Aug 2018 10:18:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frl17-0003gj-Pj for emacs-devel@gnu.org; Mon, 20 Aug 2018 10:18:53 -0400 Original-Received: from [195.159.176.226] (port=55811 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frl17-0003fk-H4 for emacs-devel@gnu.org; Mon, 20 Aug 2018 10:18:49 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1frkyy-0006zN-9C for emacs-devel@gnu.org; Mon, 20 Aug 2018 16:16:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 217 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:l0ndNnMoHo9SrKK07LJfz91s+G4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228724 Archived-At: --=-=-= Content-Type: text/plain On Mon 20 Aug 2018, Ken Brown wrote: > On 8/17/2018 10:31 AM, Eli Zaretskii wrote: >> branch: master >> commit cc5325b0bea13bd93478fcee0b035877b3a72290 >> Author: Andy Moreton >> Commit: Eli Zaretskii >> >> Pacify -Wcast-function-type warnings in GCC 8.1 >> * src/w32.h: (get_proc_addr): New function. >> * src/w32fns.c (setup_w32_kbdhook, Ffile_system_info) >> * src/w32uniscribe.c (syms_of_w32uniscribe): Use get_proc_addr. > > This breaks the Cygwin-w32 build because w32fns.c and w32uniscribe.c don't > include w32.h on Cygwin, so get_proc_addr is undefined. Could the definition > of get_proc_addr be moved to a different header that gets included in the > Cygwin build? Maybe w32common.h? Sorry Ken, I forgot to test this Cygwin as well as mingw32 and mingw64. Does something like this patch work for you ? AndyM --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=cygwin-fix-get-proc-addr.patch diff --git a/src/decompress.c b/src/decompress.c index 9f7fbe4195..2836338216 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -30,6 +30,7 @@ along with GNU Emacs. If not, see . */ #ifdef WINDOWSNT # include +# include "w32common.h" # include "w32.h" DEF_DLL_FN (int, inflateInit2_, diff --git a/src/gnutls.c b/src/gnutls.c index 2d455ea1ba..aa5c97532f 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -58,6 +58,7 @@ along with GNU Emacs. If not, see . */ # ifdef WINDOWSNT # include +# include "w32common.h" # include "w32.h" # endif diff --git a/src/image.c b/src/image.c index 7866b9cc46..b9ff3f25c4 100644 --- a/src/image.c +++ b/src/image.c @@ -77,6 +77,7 @@ typedef struct x_bitmap_record Bitmap_Record; /* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */ #ifdef WINDOWSNT +# include "w32common.h" # include "w32.h" #endif diff --git a/src/json.c b/src/json.c index 4e413a2bd5..4e46640a0c 100644 --- a/src/json.c +++ b/src/json.c @@ -34,6 +34,7 @@ along with GNU Emacs. If not, see . */ #ifdef WINDOWSNT # include +# include "w32common.h" # include "w32.h" DEF_DLL_FN (void, json_set_alloc_funcs, diff --git a/src/lcms.c b/src/lcms.c index a3a9822306..f37f843e50 100644 --- a/src/lcms.c +++ b/src/lcms.c @@ -34,6 +34,7 @@ typedef struct #ifdef WINDOWSNT # include +# include "w32common.h" # include "w32.h" DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE, diff --git a/src/w32.h b/src/w32.h index a053ee0fc4..9c219cdda6 100644 --- a/src/w32.h +++ b/src/w32.h @@ -164,10 +164,6 @@ extern void reset_standard_handles (int in, int out, /* Return the string resource associated with KEY of type TYPE. */ extern LPBYTE w32_get_resource (const char * key, LPDWORD type); -/* Load a function from a DLL. Defined in this file. */ -typedef void (* VOIDFNPTR) (void); -INLINE VOIDFNPTR get_proc_addr (HINSTANCE handle, LPCSTR fname); - extern void release_listen_threads (void); extern void init_ntproc (int); extern void term_ntproc (int); @@ -245,33 +241,4 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, const void* buf, size_t sz); #endif /* HAVE_GNUTLS */ - - -/* Load a function address from a DLL. Cast the result via "VOIDFNPTR" - to pacify -Wcast-function-type in GCC 8.1. */ -INLINE VOIDFNPTR -get_proc_addr (HINSTANCE handle, LPCSTR fname) -{ - return (VOIDFNPTR) GetProcAddress (handle, fname); -} - -/* Define a function that will be loaded from a DLL. The variable - arguments should contain the argument list for the function, and - optionally be followed by function attributes. For example: - DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN); - */ -#define DEF_DLL_FN(type, func, ...) \ - typedef type (CDECL *W32_PFN_##func) __VA_ARGS__; \ - static W32_PFN_##func fn_##func - -/* Load a function from the DLL. */ -#define LOAD_DLL_FN(lib, func) \ - do \ - { \ - fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \ - if (!fn_##func) \ - return false; \ - } \ - while (false) - #endif /* EMACS_W32_H */ diff --git a/src/w32common.h b/src/w32common.h index af548dd8ea..4981bdfd89 100644 --- a/src/w32common.h +++ b/src/w32common.h @@ -50,4 +50,34 @@ extern int os_subtype; /* Cache system info, e.g., the NT page size. */ extern void cache_system_info (void); +typedef void (* VOIDFNPTR) (void); + +/* Load a function address from a DLL. Cast the result via VOIDFNPTR + to pacify -Wcast-function-type in GCC 8.1. The return value must + be cast to the correct function pointer type. */ +INLINE VOIDFNPTR +get_proc_addr (HINSTANCE handle, LPCSTR fname) +{ + return (VOIDFNPTR) GetProcAddress (handle, fname); +} + +/* Define a function that will be loaded from a DLL. The variable + arguments should contain the argument list for the function, and + optionally be followed by function attributes. For example: + DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN); + */ +#define DEF_DLL_FN(type, func, ...) \ + typedef type (CDECL *W32_PFN_##func) __VA_ARGS__; \ + static W32_PFN_##func fn_##func + +/* Load a function from the DLL. */ +#define LOAD_DLL_FN(lib, func) \ + do \ + { \ + fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \ + if (!fn_##func) \ + return false; \ + } \ + while (false) + #endif /* W32COMMON_H */ diff --git a/src/w32font.c b/src/w32font.c index f613061832..798869b5ca 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -29,6 +29,7 @@ along with GNU Emacs. If not, see . */ #include "coding.h" /* for ENCODE_SYSTEM, DECODE_SYSTEM */ #include "w32font.h" #ifdef WINDOWSNT +#include "w32common.h" #include "w32.h" #endif diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 54f161690b..29c9c7a0bd 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c @@ -36,6 +36,7 @@ along with GNU Emacs. If not, see . */ #include "composite.h" #include "font.h" #include "w32font.h" +#include "w32common.h" struct uniscribe_font_info { diff --git a/src/xml.c b/src/xml.c index 5f3ccc85c8..e85891d2a2 100644 --- a/src/xml.c +++ b/src/xml.c @@ -31,6 +31,7 @@ along with GNU Emacs. If not, see . */ #ifdef WINDOWSNT # include +# include "w32common.h" # include "w32.h" DEF_DLL_FN (htmlDocPtr, htmlReadMemory, --=-=-=--