Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1408 serge 1
#ifndef TYPECHECK_H_INCLUDED
2
#define TYPECHECK_H_INCLUDED
3
 
4
/*
5
 * Check at compile time that something is of a particular type.
6
 * Always evaluates to 1 so you may use it easily in comparisons.
7
 */
8
#define typecheck(type,x) \
9
({	type __dummy; \
10
	typeof(x) __dummy2; \
11
	(void)(&__dummy == &__dummy2); \
12
	1; \
13
})
14
 
15
/*
16
 * Check at compile time that 'function' is a certain type, or is a pointer
17
 * to that type (needs to use typedef for the function type.)
18
 */
19
#define typecheck_fn(type,function) \
20
({	typeof(type) __tmp = function; \
21
	(void)__tmp; \
22
})
23
 
24
#endif		/* TYPECHECK_H_INCLUDED */