Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Use KHRONOS_APIENTRY to fix Win32 crash #263

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

paradust7
Copy link
Contributor

@paradust7 paradust7 commented Dec 17, 2023

Proposed solution to Windows 32-bit build crash.

The crash is caused by a calling convention mismatch. The default calling convention is cdecl, but the OpenGL functions returned by getProcAddress() are stdcall. This causes stack corruption unless function pointers are annotated with __stdcall.

For reference, this is how SDL3 determines the calling convention:

https://github.com/libsdl-org/SDL/blob/72b7acfe8ac26498dac57d751e1b3485d30a62e3/include/SDL3/SDL_opengl.h#L92-L103

This is how KHRONOS_APIENTRY is determined:

#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif

@paradust7 paradust7 changed the title Set APIENTRY to KHRONOS_APIENTRY for Win32 Use KHRONOS_APIENTRY to fix Win32 crash Dec 17, 2023
@sfan5 sfan5 merged commit 94cb0cc into minetest:master Dec 17, 2023
14 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants