Skip to content

Clang -Wcast-function-type-mismatch warning causing build failure #354

@ajkhoury

Description

@ajkhoury

A -Wcast-function-type-mismatch warning 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. I've opened a PR with the appropriate fix which adds a void pointer cast before casting to fptr_t which effectively ignores this warning.

see #351

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions