Skip to content

Conversation

ajkhoury
Copy link

This fixes a -Wcast-function-type-mismatch warning that is generated when compiling examples using Clang on Windows:

.../xed/wkit/examples/xed-util-disas-pecoff.cpp:87:8: error: cast from 'FARPROC' (aka 'long long (*)()') to 'fptr_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]
   87 |    p = (fptr_t) GetProcAddress(
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
   88 |                    GetModuleHandle(TEXT("kernel32.dll")), 
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   89 |                    function_name);
      |                    ~~~~~~~~~~~~~~
1 error generated.

This causes a compiler error due to -Werror being set by default. This commit adds a void pointer cast before casting to fptr_t which effectively ignores this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant