Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32: drop -Wno-incompatible-pointer-types when pedantic #1094

Closed
wants to merge 1 commit into from

Conversation

carenas
Copy link
Contributor

@carenas carenas commented Sep 22, 2021

27e0c3c (win32: allow building with pedantic mode enabled, 2021-09-03)
adds -W as a workaround to the use of void * to hold a pointer to a
function, punting the final solution.

The type used in Windows is a generic function type, but assigning it
from a different function interface will require a cast that was
missing from the original implementation, so lets add that.

Sadly; that is not enough, as gcc will helpfully raise a -Wcast-function-type
warnig when casting between functions that might have incompatible
return types (ex: GetUserNameExW returns bool which is only half the
size of the return type from FAPROC), so create a new type that could be
used as a completely generic function pointer, which then could be assigned
to the correct function pointer through a cast.

This has the advantage that the generic pointer functions then will be
opaque and not useful as functions without being assigned to the right
function pointer variable (just like void * was meant to be in POSIX).

Signed-off-by: Carlo Marcelo Arenas Belón carenas@gmail.com

27e0c3c (win32: allow building with pedantic mode enabled, 2021-09-03)
adds -W as a workaround to the use of `void *` to hold a pointer to a
function, punting the final solution.

The type used in Windows is a generic function type, but assigning it
from a different function interface will require a cast that was
missing from the original implementation, so lets add that.

Sadly; that is not enough, as gcc will helpfully raise a -Wcast-function-type
warnig when casting between functions that might have incompatible
return types (ex: GetUserNameExW returns bool which is only half the
size of the return type from FAPROC), so create a new type that could be
used as a completely generic function pointer, which then could be assigned
to the correct function pointer through a cast.

This has the advantage that the generic pointer functions then will be
opaque and not useful as functions without being assigned to the right
function pointer variable (just like `void *` was meant to be in POSIX).

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
@carenas
Copy link
Contributor Author

carenas commented Sep 23, 2021

@carenas carenas closed this Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant