From e080de9a6b37e806dcd7b4814926a1b59b64d2cc Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 18 Jun 2025 06:07:10 +0200 Subject: [PATCH] Stop using declarators with unspecified arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit References: https://github.com/gap-system/gap/pull/6010 GCC 15/-std=c23: ``` src/bool.c:332:22: error: passing argument 1 of 'InitHandlerFunc' from incompatible pointer type [-Wincompatible-pointer-types] 332 | InitHandlerFunc( ReturnTrue1, "src/bool.c:ReturnTrue1" ); [ 19s] src/calls.h:416:30: note: expected ‘ObjFunc’ {aka ‘struct OpaqueBag * (*)(void)’} but argument is of type ‘struct OpaqueBag * (*)(struct OpaqueBag *, struct OpaqueBag *)’ ``` Declarators with unspecified arguments `int f();` got socially deprecated with C89; since then, one can write `f(void)` for actual zero-argument functions, and `f(T, ...)` for varargs functions. C23 finally yanked declarators with unspecified arguments. Different pointer types may have different size. So you can't have one pointer type for "all kinds of functions" in plain C. Nor C++ for that matter; some use of templates/RTTI would be necessary (possibly hidden in something like std::any, but still). Or rely on platform-specific extensions, e.g. POSIX>=2001 guarantees that sizeof(void*) >= sizeof(any function pointer) and that conversion is meaningful; this is effectively mandated by the presence of dlsym(). For Windows, sizeof(FARPROC) >= sizeof(afp), effectively mandated by GetProcAddress(). Fixes: #5857 #6009 --- src/common.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/common.h b/src/common.h index 3932c3020..02818f567 100644 --- a/src/common.h +++ b/src/common.h @@ -161,12 +161,7 @@ typedef Bag Obj; ** ** 'ObjFunc' is the type of a function returning an object. */ -#pragma GCC diagnostic push -#ifndef __cplusplus -#pragma GCC diagnostic ignored "-Wstrict-prototypes" -#endif -typedef Obj (* ObjFunc) (/*arguments*/); -#pragma GCC diagnostic pop +typedef void * ObjFunc; typedef Obj (* ObjFunc_0ARGS) (Obj self); typedef Obj (* ObjFunc_1ARGS) (Obj self, Obj a1); -- 2.49.0