Clang++ build for windows

This commit is contained in:
Saksham Goyal 2025-10-03 11:48:30 -04:00
parent 8e15281d34
commit 3bec79d0a8
No known key found for this signature in database
GPG Key ID: 287D96BB5977A168
10 changed files with 54 additions and 55 deletions

View File

@ -205,8 +205,8 @@ char** _glfwParseUriList(char* text, int* count)
(*count)++;
path = _glfw_calloc(strlen(line) + 1, 1);
paths = _glfw_realloc(paths, *count * sizeof(char*));
path = (char*)_glfw_calloc(strlen(line) + 1, 1);
paths = (char**)_glfw_realloc(paths, *count * sizeof(char*));
paths[*count - 1] = path;
while (*line)
@ -231,7 +231,7 @@ char** _glfwParseUriList(char* text, int* count)
char* _glfw_strdup(const char* source)
{
const size_t length = strlen(source);
char* result = _glfw_calloc(length + 1, 1);
char* result = (char*)_glfw_calloc(length + 1, 1);
strcpy(result, source);
return result;
}
@ -357,10 +357,10 @@ void _glfwInputError(int code, const char* format, ...)
if (_glfw.initialized)
{
error = _glfwPlatformGetTls(&_glfw.errorSlot);
error = (_GLFWerror*)_glfwPlatformGetTls(&_glfw.errorSlot);
if (!error)
{
error = _glfw_calloc(1, sizeof(_GLFWerror));
error = (_GLFWerror*)_glfw_calloc(1, sizeof(_GLFWerror));
_glfwPlatformSetTls(&_glfw.errorSlot, error);
_glfwPlatformLockMutex(&_glfw.errorLock);
error->next = _glfw.errorListHead;
@ -505,7 +505,7 @@ GLFWAPI int glfwGetError(const char** description)
*description = NULL;
if (_glfw.initialized)
error = _glfwPlatformGetTls(&_glfw.errorSlot);
error = (_GLFWerror*)_glfwPlatformGetTls(&_glfw.errorSlot);
else
error = &_glfwMainThreadError;
@ -525,4 +525,3 @@ GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
return cbfun;
}

View File

@ -489,7 +489,7 @@ void _glfwInitGamepadMappings(void)
{
size_t i;
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
_glfw.mappings = (_GLFWmapping *)_glfw_calloc(count, sizeof(_GLFWmapping));
for (i = 0; i < count; i++)
{
@ -520,9 +520,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js = _glfw.joysticks + jid;
js->allocated = GLFW_TRUE;
js->axes = _glfw_calloc(axisCount, sizeof(float));
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = _glfw_calloc(hatCount, 1);
js->axes = (float *)_glfw_calloc(axisCount, sizeof(float));
js->buttons = (unsigned char *)_glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = (unsigned char *)_glfw_calloc(hatCount, 1);
js->axisCount = axisCount;
js->buttonCount = buttonCount;
js->hatCount = hatCount;
@ -858,7 +858,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
return NULL;
}
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
cursor = (_GLFWcursor *)_glfw_calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor;
@ -892,7 +892,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
return NULL;
}
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
cursor = (_GLFWcursor *)_glfw_calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor;
@ -1303,7 +1303,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
{
_glfw.mappingCount++;
_glfw.mappings =
_glfw_realloc(_glfw.mappings,
(_GLFWmapping *)_glfw_realloc(_glfw.mappings,
sizeof(_GLFWmapping) * _glfw.mappingCount);
_glfw.mappings[_glfw.mappingCount - 1] = mapping;
}

View File

@ -39,8 +39,8 @@
//
static int compareVideoModes(const void* fp, const void* sp)
{
const GLFWvidmode* fm = fp;
const GLFWvidmode* sm = sp;
const GLFWvidmode* fm = (const GLFWvidmode*)fp;
const GLFWvidmode* sm = (const GLFWvidmode*)sp;
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
const int farea = fm->width * fm->height;
@ -102,7 +102,7 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
{
_glfw.monitorCount++;
_glfw.monitors =
_glfw_realloc(_glfw.monitors,
(_GLFWmonitor **)_glfw_realloc(_glfw.monitors,
sizeof(_GLFWmonitor*) * _glfw.monitorCount);
if (placement == _GLFW_INSERT_FIRST)
@ -170,7 +170,7 @@ void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
//
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
{
_GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
_GLFWmonitor* monitor = (_GLFWmonitor*) _glfw_calloc(1, sizeof(_GLFWmonitor));
monitor->widthMM = widthMM;
monitor->heightMM = heightMM;
@ -199,9 +199,9 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
//
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
{
ramp->red = _glfw_calloc(size, sizeof(unsigned short));
ramp->green = _glfw_calloc(size, sizeof(unsigned short));
ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
ramp->red = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->green = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->blue = (unsigned short*)_glfw_calloc(size, sizeof(unsigned short));
ramp->size = size;
}

View File

@ -112,7 +112,7 @@ GLFWbool _glfwInitVulkan(int mode)
return GLFW_FALSE;
}
ep = _glfw_calloc(count, sizeof(VkExtensionProperties));
ep = (VkExtensionProperties*)_glfw_calloc(count, sizeof(VkExtensionProperties));
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
if (err)

View File

@ -134,7 +134,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
nativeCount = _glfw_min(nativeCount, extensionCount);
}
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableConfigs = (_GLFWfbconfig *)_glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
for (i = 0; i < nativeCount; i++)
{
@ -346,7 +346,7 @@ static void swapBuffersWGL(_GLFWwindow* window)
static void swapIntervalWGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
_GLFWwindow* window = (_GLFWwindow*)_glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
window->context.wgl.interval = interval;
@ -412,7 +412,7 @@ GLFWbool _glfwInitWGL(void)
if (_glfw.wgl.instance)
return GLFW_TRUE;
_glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
_glfw.wgl.instance = (HINSTANCE)_glfwPlatformLoadModule("opengl32.dll");
if (!_glfw.wgl.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,

View File

@ -81,7 +81,7 @@ static GLFWbool loadLibraries(void)
return GLFW_FALSE;
}
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
_glfw.win32.user32.instance = (HINSTANCE)_glfwPlatformLoadModule("user32.dll");
if (!_glfw.win32.user32.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -100,7 +100,7 @@ static GLFWbool loadLibraries(void)
_glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
_glfw.win32.dinput8.instance = (HINSTANCE)_glfwPlatformLoadModule("dinput8.dll");
if (_glfw.win32.dinput8.instance)
{
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
@ -121,7 +121,7 @@ static GLFWbool loadLibraries(void)
for (i = 0; names[i]; i++)
{
_glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]);
_glfw.win32.xinput.instance = (HINSTANCE)_glfwPlatformLoadModule(names[i]);
if (_glfw.win32.xinput.instance)
{
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
@ -134,7 +134,7 @@ static GLFWbool loadLibraries(void)
}
}
_glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
_glfw.win32.dwmapi.instance = (HINSTANCE)_glfwPlatformLoadModule("dwmapi.dll");
if (_glfw.win32.dwmapi.instance)
{
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
@ -147,7 +147,7 @@ static GLFWbool loadLibraries(void)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
}
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
_glfw.win32.shcore.instance = (HINSTANCE)_glfwPlatformLoadModule("shcore.dll");
if (_glfw.win32.shcore.instance)
{
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
@ -156,7 +156,7 @@ static GLFWbool loadLibraries(void)
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor");
}
_glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll");
_glfw.win32.ntdll.instance = (HINSTANCE)_glfwPlatformLoadModule("ntdll.dll");
if (_glfw.win32.ntdll.instance)
{
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
@ -445,7 +445,7 @@ WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
return NULL;
}
target = _glfw_calloc(count, sizeof(WCHAR));
target = (WCHAR *)_glfw_calloc(count, sizeof(WCHAR));
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
{
@ -473,7 +473,7 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
return NULL;
}
target = _glfw_calloc(size, 1);
target = (char*)_glfw_calloc(size, 1);
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
{

View File

@ -178,8 +178,8 @@ static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
//
static int compareJoystickObjects(const void* first, const void* second)
{
const _GLFWjoyobjectWin32* fo = first;
const _GLFWjoyobjectWin32* so = second;
const _GLFWjoyobjectWin32* fo = (const _GLFWjoyobjectWin32 *)first;
const _GLFWjoyobjectWin32* so = (const _GLFWjoyobjectWin32 *)second;
if (fo->type != so->type)
return fo->type - so->type;
@ -199,7 +199,7 @@ static GLFWbool supportsXInput(const GUID* guid)
if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
return GLFW_FALSE;
ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
ridl = (RAWINPUTDEVICELIST *)_glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
{
@ -274,7 +274,7 @@ static void closeJoystick(_GLFWjoystick* js)
static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
void* user)
{
_GLFWobjenumWin32* data = user;
_GLFWobjenumWin32* data = (_GLFWobjenumWin32 *)user;
_GLFWjoyobjectWin32* object = data->objects + data->objectCount;
if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
@ -416,7 +416,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
memset(&data, 0, sizeof(data));
data.device = device;
data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
data.objects = (_GLFWjoyobjectWin32 *)_glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
sizeof(_GLFWjoyobjectWin32));
if (FAILED(IDirectInputDevice8_EnumObjects(device,

View File

@ -145,7 +145,7 @@ void _glfwPollMonitorsWin32(void)
disconnectedCount = _glfw.monitorCount;
if (disconnectedCount)
{
disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
disconnected = (_GLFWmonitor**)_glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
memcpy(disconnected,
_glfw.monitors,
_glfw.monitorCount * sizeof(_GLFWmonitor*));
@ -463,7 +463,7 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
if (!*count)
{
// HACK: Report the current mode if no valid modes were found
result = _glfw_calloc(1, sizeof(GLFWvidmode));
result = (GLFWvidmode*)_glfw_calloc(1, sizeof(GLFWvidmode));
_glfwGetVideoModeWin32(monitor, result);
*count = 1;
}

View File

@ -530,7 +530,7 @@ static void maximizeWindowManually(_GLFWwindow* window)
//
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
_GLFWwindow* window = (_GLFWwindow*)GetPropW(hWnd, L"GLFW");
if (!window)
{
if (uMsg == WM_NCCREATE)
@ -538,7 +538,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
if (_glfwIsWindows10Version1607OrGreaterWin32())
{
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
const _GLFWwndconfig* wndconfig = (const _GLFWwndconfig*)cs->lpCreateParams;
// On per-monitor DPI aware V1 systems, only enable
// non-client scaling for windows that scale the client area
@ -910,7 +910,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
if (size > (UINT) _glfw.win32.rawInputSize)
{
_glfw_free(_glfw.win32.rawInput);
_glfw.win32.rawInput = _glfw_calloc(size, 1);
_glfw.win32.rawInput = (RAWINPUT *)_glfw_calloc(size, 1);
_glfw.win32.rawInputSize = size;
}
@ -1236,7 +1236,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
int i;
const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
char** paths = _glfw_calloc(count, sizeof(char*));
char** paths = (char**)_glfw_calloc(count, sizeof(char*));
// Move the mouse to the position of the drop
DragQueryPoint(drop, &pt);
@ -1245,7 +1245,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
for (i = 0; i < count; i++)
{
const UINT length = DragQueryFileW(drop, i, NULL, 0);
WCHAR* buffer = _glfw_calloc((size_t) length + 1, sizeof(WCHAR));
WCHAR* buffer = (WCHAR*)_glfw_calloc((size_t) length + 1, sizeof(WCHAR));
DragQueryFileW(drop, i, buffer, length + 1);
paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
@ -1291,13 +1291,13 @@ static int createNativeWindow(_GLFWwindow* window,
wc.lpszClassName = L"GLFW30";
#endif
// Load user-provided icon if available
wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
wc.hIcon = (HICON)LoadImageW(GetModuleHandleW(NULL),
L"GLFW_ICON", IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED);
if (!wc.hIcon)
{
// No user-provided icon found, load default icon
wc.hIcon = LoadImageW(NULL,
wc.hIcon = (HICON)LoadImageW(NULL,
IDI_APPLICATION, IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED);
}
@ -1321,7 +1321,7 @@ static int createNativeWindow(_GLFWwindow* window,
const int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
const int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4);
unsigned char* cursorPixels = (unsigned char*)_glfw_calloc(cursorWidth * cursorHeight, 4);
if (!cursorPixels)
return GLFW_FALSE;
@ -1769,7 +1769,7 @@ void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float*
{
const HANDLE handle = MonitorFromWindow(window->win32.handle,
MONITOR_DEFAULTTONEAREST);
_glfwGetHMONITORContentScaleWin32(handle, xscale, yscale);
_glfwGetHMONITORContentScaleWin32((HMONITOR)handle, xscale, yscale);
}
void _glfwIconifyWindowWin32(_GLFWwindow* window)
@ -2124,7 +2124,7 @@ void _glfwPollEventsWin32(void)
handle = GetActiveWindow();
if (handle)
{
window = GetPropW(handle, L"GLFW");
window = (_GLFWwindow*)GetPropW(handle, L"GLFW");
if (window)
{
int i;
@ -2326,7 +2326,7 @@ GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
return GLFW_FALSE;
}
cursor->win32.handle = LoadImageW(NULL,
cursor->win32.handle = (HCURSOR)LoadImageW(NULL,
MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE | LR_SHARED);
if (!cursor->win32.handle)
@ -2369,7 +2369,7 @@ void _glfwSetClipboardStringWin32(const char* string)
return;
}
buffer = GlobalLock(object);
buffer = (WCHAR *)GlobalLock(object);
if (!buffer)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -2432,7 +2432,7 @@ const char* _glfwGetClipboardStringWin32(void)
return NULL;
}
buffer = GlobalLock(object);
buffer = (WCHAR *)GlobalLock(object);
if (!buffer)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@ -2480,7 +2480,7 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
if (type)
{
*attribs = _glfw_calloc(3, sizeof(EGLint));
*attribs = (EGLint *)_glfw_calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;

View File

@ -213,7 +213,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (!_glfwIsValidContextConfig(&ctxconfig))
return NULL;
window = _glfw_calloc(1, sizeof(_GLFWwindow));
window = (_GLFWwindow *)_glfw_calloc(1, sizeof(_GLFWwindow));
window->next = _glfw.windowListHead;
_glfw.windowListHead = window;