all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: andrewjmoreton@gmail.com, eggert@cs.ucla.edu, bug-gnulib@gnu.org,
	emacs-devel@gnu.org
Subject: Re: New warnings on emacs-26 branch with gcc 8.2.0
Date: Sat, 18 Aug 2018 23:25:56 +0200	[thread overview]
Message-ID: <2510628.alnMaqBdeU@omega> (raw)
In-Reply-To: <83d0uffrft.fsf@gnu.org>

Eli Zaretskii wrote:
> There's also this additional option:
> 
>   5) Cast through (void *).  Like this:
> 
>       GetSystemTimePreciseAsFileTimeFunc =
>         (GetSystemTimePreciseAsFileTimeFuncType) (void (*) (void)) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");

Indeed, casting through (void *) or (void (*) (void)) avoids the
warning. I'm going to test this patch:


2018-08-18  Bruno Haible  <bruno@clisp.org>

	Avoid -Wcast-function-type warnings from casts after GetProcAddress.
	Reported by Andy Moreton <andrewjmoreton@gmail.com> in
	<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
	Solution proposed by Eli Zaretskii.
	* lib/getaddrinfo.c (GetProcAddress): Cast result to 'void *' first.
	* lib/gettimeofday.c (GetProcAddress): Likewise.
	* lib/link.c (GetProcAddress): Likewise.
	* lib/physmem.c (GetProcAddress): Likewise.
	* lib/poll.c (GetProcAddress): Likewise.
	* lib/select.c (GetProcAddress): Likewise.
	* lib/stat-w32.c (GetProcAddress): Likewise.

diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 756c31b..7bf38e8 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -62,6 +62,11 @@
 #include "sockets.h"
 
 #ifdef WINDOWS_NATIVE
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
                                         const struct addrinfo*,
                                         struct addrinfo**);
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index bff40d7..36b5074 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -33,6 +33,10 @@
 
 #ifdef WINDOWS_NATIVE
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8.  */
 typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
 static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
diff --git a/lib/link.c b/lib/link.c
index bf0b344..cff54a2 100644
--- a/lib/link.c
+++ b/lib/link.c
@@ -30,6 +30,10 @@
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#  define GetProcAddress \
+    (void *) GetProcAddress
+
 /* CreateHardLink was introduced only in Windows 2000.  */
 typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName,
                                                 LPCTSTR lpExistingFileName,
diff --git a/lib/physmem.c b/lib/physmem.c
index cbb33ac..c89c0f0 100644
--- a/lib/physmem.c
+++ b/lib/physmem.c
@@ -59,8 +59,14 @@
 #endif
 
 #ifdef _WIN32
+
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /*  MEMORYSTATUSEX is missing from older windows headers, so define
     a local replacement.  */
 typedef struct
@@ -76,6 +82,7 @@ typedef struct
   DWORDLONG ullAvailExtendedVirtual;
 } lMEMORYSTATUSEX;
 typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*);
+
 #endif
 
 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
diff --git a/lib/poll.c b/lib/poll.c
index 26f7f12..576ec9f 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -84,6 +84,10 @@
    of SOCKETs, not bit masks of FDs.  */
 # undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 static BOOL IsConsoleHandle (HANDLE h)
 {
   DWORD mode;
diff --git a/lib/select.c b/lib/select.c
index 3659cb5..ffb58ee 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -47,6 +47,10 @@
 
 #undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 struct bitset {
   unsigned char in[FD_SETSIZE / CHAR_BIT];
   unsigned char out[FD_SETSIZE / CHAR_BIT];
diff --git a/lib/stat-w32.c b/lib/stat-w32.c
index 802b38a..c7a53f9 100644
--- a/lib/stat-w32.c
+++ b/lib/stat-w32.c
@@ -38,6 +38,10 @@
 #include "pathmax.h"
 #include "verify.h"
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 #if _GL_WINDOWS_STAT_INODES == 2
 /* GetFileInformationByHandleEx was introduced only in Windows Vista.  */
 typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,




  parent reply	other threads:[~2018-08-18 21:25 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-05 16:33 New warnings on emacs-26 branch with gcc 8.2.0 Andy Moreton
2018-08-05 16:41 ` Noam Postavsky
2018-08-05 19:56 ` Paul Eggert
2018-08-05 22:23   ` Andy Moreton
2018-08-05 22:47     ` Paul Eggert
2018-08-06  8:30       ` Andy Moreton
2018-08-06 15:16         ` Eli Zaretskii
2018-08-06 15:26           ` Andy Moreton
2018-08-06 15:34             ` Eli Zaretskii
2018-08-06 18:37         ` Paul Eggert
2018-08-06 21:36           ` Andy Moreton
2018-08-06 21:58             ` Paul Eggert
2018-08-11 15:06               ` Andy Moreton
2018-08-11 19:23                 ` Paul Eggert
2018-08-11 19:38                   ` Andy Moreton
2018-08-11 20:13                     ` Paul Eggert
2018-08-06  2:26   ` Eli Zaretskii
2018-08-06  3:16     ` Paul Eggert
2018-08-11  8:40       ` Eli Zaretskii
2018-08-11 10:41         ` Andy Moreton
2018-08-11 10:51           ` Eli Zaretskii
2018-08-11 15:02             ` Andy Moreton
2018-08-11 17:15               ` Eli Zaretskii
2018-08-11 18:13                 ` Andy Moreton
2018-08-11 18:26                   ` Eli Zaretskii
2018-08-11 18:36                     ` Andy Moreton
2018-08-11 19:04                       ` Andy Moreton
2018-08-11 19:10                         ` Eli Zaretskii
2018-08-14 12:59                           ` Andy Moreton
2018-08-14 21:20                             ` Andy Moreton
2018-08-14 22:32                               ` Paul Eggert
2018-08-17 14:33                                 ` Eli Zaretskii
2018-08-18 16:09                                 ` Bruno Haible
2018-08-18 17:19                                   ` Paul Eggert
2018-08-18 18:33                                     ` Bruno Haible
2018-08-18 18:44                                     ` Eli Zaretskii
2018-08-18 18:59                                       ` Paul Eggert
2018-08-18 19:17                                         ` Eli Zaretskii
2018-08-18 19:57                                           ` Paul Eggert
2018-08-18 18:41                                   ` Eli Zaretskii
2018-08-18 19:07                                     ` Andy Moreton
2018-08-18 21:25                                     ` Bruno Haible [this message]
2018-08-19  0:17                                       ` Bruno Haible
2018-08-19  2:44                                         ` Eli Zaretskii
2018-08-19  7:08                                       ` Yuri Khan
2018-08-19  8:40                                         ` Bruno Haible
2018-08-20  3:01                                       ` Richard Stallman
2018-08-20  8:20                                         ` Andy Moreton
2018-08-21  3:37                                           ` Richard Stallman
2018-08-21  3:43                                             ` Paul Eggert
2018-08-22  4:03                                               ` Richard Stallman
2018-08-17 14:32                             ` Eli Zaretskii
2018-08-17 15:21                               ` Andy Moreton
2018-08-17 19:45                                 ` Eli Zaretskii
2018-08-17 21:33                                   ` Andy Moreton
2018-08-18  6:25                                     ` Eli Zaretskii
2018-08-11 19:18                       ` Paul Eggert
2018-08-15 15:53                         ` Andy Moreton
2018-08-16 21:05                           ` Paul Eggert
2018-08-17 14:34                           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2510628.alnMaqBdeU@omega \
    --to=bruno@clisp.org \
    --cc=andrewjmoreton@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.