ath9k-hmac/backports-3.12.8-1/backport-include/backport/magic.h
2016-09-26 15:44:25 +02:00

17 lines
509 B
C

/*
* These tricks are taken from
* http://efesx.com/2010/07/17/variadic-macro-to-count-number-of-arguments/
* and
* http://efesx.com/2010/08/31/overloading-macros/
*/
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(func, ...) \
macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(func, nargs) \
macro_dispatcher__(func, nargs)
#define macro_dispatcher__(func, nargs) \
func ## nargs