diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 79b06288..4d46ce69 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1180,7 +1180,7 @@ extern "C" { #define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001 #define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002 -#define GLFW_ANY_POSITION 0x80000000 +#define GLFW_ANY_POSITION 0x7FFFFFFF /*! @defgroup shapes Standard cursor shapes * @brief Standard system cursor shapes. diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 4d1d66ae..3d1a89fc 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -272,7 +272,7 @@ EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs); EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void); EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window); -void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions); +void _glfwGetRequiredInstanceExtensionsCocoa(const char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e69b5fe0..4a5997a4 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1922,7 +1922,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window) return window->ns.layer; } -void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions) +void _glfwGetRequiredInstanceExtensionsCocoa(const char** extensions) { if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) { diff --git a/src/input.c b/src/input.c index c619eefc..ba613e0c 100644 --- a/src/input.c +++ b/src/input.c @@ -1289,7 +1289,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) const size_t length = strcspn(c, "\r\n"); if (length < sizeof(line)) { - _GLFWmapping mapping = {{0}}; + _GLFWmapping mapping = { .name = {0} }; memcpy(line, c, length); line[length] = '\0'; diff --git a/src/internal.h b/src/internal.h index 4f097aa8..dc4d2c0d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -756,7 +756,7 @@ struct _GLFWplatform EGLNativeDisplayType (*getEGLNativeDisplay)(void); EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*); // vulkan - void (*getRequiredInstanceExtensions)(char**); + void (*getRequiredInstanceExtensions)(const char**); GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); }; @@ -863,7 +863,7 @@ struct _GLFWlibrary struct { GLFWbool available; void* handle; - char* extensions[2]; + const char* extensions[2]; PFN_vkGetInstanceProcAddr GetInstanceProcAddr; GLFWbool KHR_surface; GLFWbool KHR_win32_surface; diff --git a/src/null_platform.h b/src/null_platform.h index dbcb835b..9d19b6d6 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -274,7 +274,7 @@ EGLenum _glfwGetEGLPlatformNull(EGLint** attribs); EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void); EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window); -void _glfwGetRequiredInstanceExtensionsNull(char** extensions); +void _glfwGetRequiredInstanceExtensionsNull(const char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); diff --git a/src/null_window.c b/src/null_window.c index f0e1dcc9..83b7b7fd 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -701,7 +701,7 @@ int _glfwGetKeyScancodeNull(int key) return _glfw.null.scancodes[key]; } -void _glfwGetRequiredInstanceExtensionsNull(char** extensions) +void _glfwGetRequiredInstanceExtensionsNull(const char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface) return; diff --git a/src/posix_module.c b/src/posix_module.c index b3482d26..12850b8a 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -44,10 +44,17 @@ void _glfwPlatformFreeModule(void* module) dlclose(module); } +#if defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" +#endif GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) { - return dlsym(module, name); + return (GLFWproc)dlsym(module, name); } +#if defined(__GNUC__) + #pragma GCC diagnostic pop +#endif #endif // GLFW_BUILD_POSIX_MODULE diff --git a/src/vulkan.c b/src/vulkan.c index 9c87fcfe..9182043d 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -150,7 +150,7 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.available = GLFW_TRUE; - _glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions); + _glfw.platform.getRequiredInstanceExtensions((const char **)_glfw.vk.extensions); return GLFW_TRUE; } diff --git a/src/win32_platform.h b/src/win32_platform.h index a2f86852..8365b312 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -600,7 +600,7 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs); EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void); EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window); -void _glfwGetRequiredInstanceExtensionsWin32(char** extensions); +void _glfwGetRequiredInstanceExtensionsWin32(const char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); diff --git a/src/win32_window.c b/src/win32_window.c index d014944b..ce17918b 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2514,7 +2514,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window) return window->win32.handle; } -void _glfwGetRequiredInstanceExtensionsWin32(char** extensions) +void _glfwGetRequiredInstanceExtensionsWin32(const char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface) return; diff --git a/src/wl_init.c b/src/wl_init.c index ef9e4503..0b7723ac 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -243,7 +243,7 @@ void libdecorHandleError(struct libdecor* context, static const struct libdecor_interface libdecorInterface = { - libdecorHandleError + .error = libdecorHandleError }; static void libdecorReadyCallback(void* userData, diff --git a/src/wl_platform.h b/src/wl_platform.h index afa6f50a..86b1d95f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -673,7 +673,7 @@ EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs); EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void); EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window); -void _glfwGetRequiredInstanceExtensionsWayland(char** extensions); +void _glfwGetRequiredInstanceExtensionsWayland(const char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); diff --git a/src/wl_window.c b/src/wl_window.c index 72c1a402..d2278627 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -474,8 +474,8 @@ static void surfaceHandleLeave(void* userData, static const struct wl_surface_listener surfaceListener = { - surfaceHandleEnter, - surfaceHandleLeave + .enter = surfaceHandleEnter, + .leave = surfaceHandleLeave }; static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable) @@ -616,8 +616,8 @@ static void xdgToplevelHandleClose(void* userData, static const struct xdg_toplevel_listener xdgToplevelListener = { - xdgToplevelHandleConfigure, - xdgToplevelHandleClose + .configure = xdgToplevelHandleConfigure, + .close = xdgToplevelHandleClose }; static void xdgSurfaceHandleConfigure(void* userData, @@ -791,10 +791,10 @@ void libdecorFrameHandleDismissPopup(struct libdecor_frame* frame, static const struct libdecor_frame_interface libdecorFrameInterface = { - libdecorFrameHandleConfigure, - libdecorFrameHandleClose, - libdecorFrameHandleCommit, - libdecorFrameHandleDismissPopup + .configure = libdecorFrameHandleConfigure, + .close = libdecorFrameHandleClose, + .commit = libdecorFrameHandleCommit, + .dismiss_popup = libdecorFrameHandleDismissPopup }; static GLFWbool createLibdecorFrame(_GLFWwindow* window) @@ -1144,7 +1144,7 @@ static GLFWbool flushDisplay(void) if (errno != EAGAIN) return GLFW_FALSE; - struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLOUT }; + struct pollfd fd = { .fd = wl_display_get_fd(_glfw.wl.display), POLLOUT }; while (poll(&fd, 1, -1) == -1) { @@ -1624,11 +1624,11 @@ static void pointerHandleAxis(void* userData, static const struct wl_pointer_listener pointerListener = { - pointerHandleEnter, - pointerHandleLeave, - pointerHandleMotion, - pointerHandleButton, - pointerHandleAxis, + .enter = pointerHandleEnter, + .leave = pointerHandleLeave, + .motion = pointerHandleMotion, + .button = pointerHandleButton, + .axis = pointerHandleAxis, }; static void keyboardHandleKeymap(void* userData, @@ -1936,7 +1936,7 @@ static void dataOfferHandleOffer(void* userData, static const struct wl_data_offer_listener dataOfferListener = { - dataOfferHandleOffer + .offer = dataOfferHandleOffer }; static void dataDeviceHandleDataOffer(void* userData, @@ -1955,7 +1955,7 @@ static void dataDeviceHandleDataOffer(void* userData, _glfw.wl.offers = offers; _glfw.wl.offerCount++; - _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer }; + _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { .offer = offer }; wl_data_offer_add_listener(offer, &dataOfferListener, NULL); } @@ -3139,9 +3139,9 @@ static void dataSourceHandleCancelled(void* userData, static const struct wl_data_source_listener dataSourceListener = { - dataSourceHandleTarget, - dataSourceHandleSend, - dataSourceHandleCancelled, + .target = dataSourceHandleTarget, + .send = dataSourceHandleSend, + .cancelled = dataSourceHandleCancelled, }; void _glfwSetClipboardStringWayland(const char* string) @@ -3215,7 +3215,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window) return window->wl.egl.window; } -void _glfwGetRequiredInstanceExtensionsWayland(char** extensions) +void _glfwGetRequiredInstanceExtensionsWayland(const char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface) return; diff --git a/src/x11_init.c b/src/x11_init.c index 6b34c263..436e105b 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -231,7 +231,7 @@ static void createKeyTables(void) const struct { int key; - char* name; + const char* name; } keymap[] = { { GLFW_KEY_GRAVE_ACCENT, "TLDE" }, @@ -366,7 +366,7 @@ static void createKeyTables(void) // keyboard layout. Because function keys aren't mapped correctly // when using traditional KeySym translations, they are mapped // here instead. - for (int i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++) + for (size_t i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++) { if (strncmp(desc->names->keys[scancode].name, keymap[i].name, @@ -390,7 +390,7 @@ static void createKeyTables(void) continue; } - for (int j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++) + for (size_t j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++) { if (strncmp(desc->names->key_aliases[i].alias, keymap[j].name, diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 3af82752..3c7134d5 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -180,8 +180,8 @@ void _glfwPollMonitorsX11(void) { if (screens[j].x_org == ci->x && screens[j].y_org == ci->y && - screens[j].width == ci->width && - screens[j].height == ci->height) + screens[j].width == (int)ci->width && + screens[j].height == (int)ci->height) { monitor->x11.index = j; break; @@ -573,7 +573,7 @@ void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { - if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size) + if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != (int)ramp->size) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Gamma ramp size must match current ramp size"); diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5b..bd2a0072 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -959,7 +959,7 @@ EGLenum _glfwGetEGLPlatformX11(EGLint** attribs); EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void); EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window); -void _glfwGetRequiredInstanceExtensionsX11(char** extensions); +void _glfwGetRequiredInstanceExtensionsX11(const char** extensions); GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); diff --git a/src/x11_window.c b/src/x11_window.c index 322349f0..2bd7632e 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -62,7 +62,7 @@ // static GLFWbool waitForX11Event(double* timeout) { - struct pollfd fd = { ConnectionNumber(_glfw.x11.display), POLLIN }; + struct pollfd fd = { .fd = ConnectionNumber(_glfw.x11.display), .events = POLLIN }; while (!XPending(_glfw.x11.display)) { @@ -97,7 +97,7 @@ static GLFWbool waitForAnyEvent(double* timeout) if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout)) return GLFW_FALSE; - for (int i = 1; i < sizeof(fds) / sizeof(fds[0]); i++) + for (size_t i = 1; i < sizeof(fds) / sizeof(fds[0]); i++) { if (fds[i].revents & POLLIN) return GLFW_TRUE; @@ -235,10 +235,10 @@ static int translateState(int state) // Translates an X11 key code to a GLFW key token // -static int translateKey(int scancode) +static int translateKey(unsigned int scancode) { // Use the pre-filled LUT (see createKeyTables() in x11_init.c) - if (scancode < 0 || scancode > 255) + if (scancode > 255) return GLFW_KEY_UNKNOWN; return _glfw.x11.keycodes[scancode]; @@ -1145,7 +1145,7 @@ static void releaseMonitor(_GLFWwindow* window) // static void processEvent(XEvent *event) { - int keycode = 0; + unsigned int keycode = 0; Bool filtered = False; // HACK: Save scancode as some IMs clear the field in XFilterEvent @@ -3133,7 +3133,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window) return (EGLNativeWindowType) window->x11.handle; } -void _glfwGetRequiredInstanceExtensionsX11(char** extensions) +void _glfwGetRequiredInstanceExtensionsX11(const char** extensions) { if (!_glfw.vk.KHR_surface) return;