Skip to content

Commit dfb3e86

Browse files
committed
Use void* to store function pointer when compiled as C23.
[0] decided that `rettype (*foo)();` must now be interpreted as `rettype (*foo)(void);`. Luckily it also allows now to store function pointers in a `void*` (c.f. Ch. J.5.7). [0]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent a81f0a8 commit dfb3e86

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/common.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@
3030
#include "snprintf.h"
3131

3232
/** handlers **/
33+
#if (__STDC_VERSION__ >= 202000L)
34+
typedef void* xmpp_void_handler;
35+
#else
36+
typedef int (*xmpp_void_handler)();
37+
#endif
3338

3439
typedef struct _xmpp_handlist_t xmpp_handlist_t;
3540
struct _xmpp_handlist_t {
3641
/* common members */
3742
int user_handler;
38-
int (*handler)();
43+
xmpp_void_handler handler;
3944
void *userdata;
4045
int enabled; /* handlers are added disabled and enabled after the
4146
* handler chain is processed to prevent stanzas from

src/handler.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "common.h"
2626
#include "ostypes.h"
2727

28-
typedef int (*xmpp_void_handler)();
29-
3028
/* Remove item from the list pointed by head, but don't free it.
3129
* There can be a situation when user's handler deletes another handler which
3230
* is the previous in the list. handler_fire_stanza() and handler_fire_timed()

0 commit comments

Comments
 (0)