[PATCH] w32: Fix clang compiler error with function pointer

Biswapriyo Nath nathbappai at gmail.com
Tue May 30 20:02:44 CEST 2023


This fixes the following compiler error

../../src/gpgme-w32spawn.c:253:20: error: incompatible function pointer
types assigning to 'BOOL (*)(DWORD) __attribute__((stdcall))'
(aka 'int (*)(unsigned long)') from 'FARPROC' (aka 'long long (*)()')
 [-Wincompatible-function-pointer-types]
func = GetProcAddress (handle, "AllowSetForegroundWindow");
     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Biswapriyo Nath <nathbappai at gmail.com>
---
 src/gpgme-w32spawn.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gpgme-w32spawn.c b/src/gpgme-w32spawn.c
index 09dbea7..8a15e7f 100644
--- a/src/gpgme-w32spawn.c
+++ b/src/gpgme-w32spawn.c
@@ -240,7 +240,8 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
   if (flags & IOSPAWN_FLAG_ALLOW_SET_FG)
     {
       static int initialized;
-      static BOOL (WINAPI * func)(DWORD);
+      typedef BOOL (WINAPI * allow_set_forground)(DWORD);
+      static allow_set_forground func;
       void *handle;
 
       if (!initialized)
@@ -250,7 +251,7 @@ my_spawn (char **argv, struct spawn_fd_item_s *fd_list, unsigned int flags)
           handle = LoadLibrary ("user32.dll");
           if (handle)
             {
-              func = GetProcAddress (handle, "AllowSetForegroundWindow");
+              func = (allow_set_forground) GetProcAddress (handle, "AllowSetForegroundWindow");
               if (!func)
                 FreeLibrary (handle);
             }
-- 
2.40.1




More information about the Gnupg-devel mailing list