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

use two-step casting to silence incompatible function type warning #249

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

bashbaug
Copy link
Contributor

@bashbaug bashbaug commented Mar 7, 2025

Looks like a recent GitHub actions change caused our Windows CI builds to fail in the clangcl config due to -Werror and -Wcast-function-type-mismatch:

D:\a\OpenCL-ICD-Loader\OpenCL-ICD-Loader\loader\windows\icd_windows.c(284,54): error : cast from 'FARPROC' (aka 'long long (*)()') to 'PFN_CREATE_DXGI_FACTORY' (aka 'long (*)(const struct _GUID *const, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch] [D:\a\OpenCL-ICD-Loader\OpenCL-ICD-Loader\build\OpenCL.vcxproj]

We can silence this warning with a two-step cast, e.g.

PFN_CREATE_DXGI_FACTORY pCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)(void*)GetProcAddress(hDXGI, "CreateDXGIFactory");

We do this a couple of other places in the OpenCL ICD loader by casting through size_t, but I think casting through void* is more common. If desired though, I can switch to size_t, or turn the other casts to void* for consistency.

@bashbaug bashbaug requested review from Kerilk and MathiasMagnus March 7, 2025 01:55
@CLAassistant
Copy link

CLAassistant commented Mar 7, 2025

CLA assistant check
All committers have signed the CLA.

@bashbaug bashbaug merged commit d615f1b into KhronosGroup:main Mar 9, 2025
33 checks passed
@bashbaug bashbaug deleted the fix-windows-clang-issue branch March 9, 2025 20:14
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.

3 participants