summaryrefslogtreecommitdiffstats
path: root/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_preargs.c
blob: bd55c6722c70bd62cf17f50d5354a1b822c9b483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <ccan/typesafe_cb/typesafe_cb.h>
#include <stdlib.h>

static void _register_callback(void (*cb)(int x, void *arg), void *arg)
{
}

#define register_callback(cb, arg)				\
	_register_callback(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg))

static void my_callback(int x, char *p)
{
}

int main(int argc, char *argv[])
{
#ifdef FAIL
	int *p;
#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
#endif
#else
	char *p;
#endif
	p = NULL;
	register_callback(my_callback, p);
	return 0;
}