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

Jacob Bachmeyer jcb62281 at gmail.com
Wed May 31 07:01:37 CEST 2023


Biswapriyo Nath wrote:
>> Is "allow_set_forground" intended or a typo for "allow_set_foreground"?
>>     
>
> Yes, I didn't notice it.
>
>   
>> Also, this looks like a clang bug:  both version of the code should
>> declare a function pointer of the same type.
>>     
>
> I do not think so. gcc also shows a compiler warning with that line as
> following.
>
> ../../src/gpgme-w32spawn.c:253:20: warning: assignment to 'BOOL
> (*)(DWORD)' {aka 'int (*)(long unsigned int)'} from incompatible
> pointer type 'FARPROC' {aka 'long long
> int (*)()'} [-Wincompatible-pointer-types]
>   253 |               func = GetProcAddress (handle,
> "AllowSetForegroundWindow");
>       |                    ^
>
> clang only treats it as a compiler error by default.
>   

Oh, right.  Your patch actually has two changes.  You should also be 
able to also cast the pointer to "(BOOL (*)(DWORD))" without naming the 
type.  E.g.

func = (BOOL (*)(DWORD)) GetProcAddress (handle, "AllowSetForegroundWindow");


... but I do not have a Windows box to test that on.


-- Jacob



More information about the Gnupg-devel mailing list