Page MenuHome GnuPG

Fix assignment of GetProcAddress to func
Needs RevisionPublic

Authored by CarlSchwan on Jun 6 2024, 4:36 PM.

Details

Summary
  • src/gpgme-w32spawn.c: Change func signature to FARPROC --

GetProcAddress is documented as returning a FARPROC. Assigning it to a
BOOL (WINAPI * )(DWORD) won't compile with -Wincompatible-pointer-types

Test Plan

Compiles

Diff Detail

Repository
rM GPGME
Branch
work/carl/fixGetProcAddress
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

CarlSchwan created this revision.

The compile error:

../../gpgme-1.24.0-beta566/src/gpgme-w32spawn.c:252:20: error: assignment to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} from incompatible pointer type 'FARPROC' {aka 'long long int (*)()'} [-Wincompatible-pointer-types]
  252 |               func = GetProcAddress (handle, "AllowSetForegroundWindow")

I think the correct fix is to C-cast the return value of GetProcAddress to the type of func which we would have to define with a typedef as in the example for GetProcAddress: https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress

This revision now requires changes to proceed.Jun 12 2024, 1:45 PM

Cast instead of using FARPROC

This revision is now accepted and ready to land.Jun 25 2024, 5:25 PM

Our Makefile does not use -Wincompatible-pointer-types for a reason. Please build gpgme only the standard way, i.e. by using ./autogen.sh --build-w32. Keep in mind that C is an entire different language than C++.

This revision now requires changes to proceed.Jun 25 2024, 5:44 PM