#include <stdio.h>
#include <stdlib.h>
#define __CONNECT2(__A, __B) __A##__B
#define CONNECT2(__A, __B) __CONNECT2(__A, __B)
#define __CONNECT3(__A, __B, __C) __A##__B##__C
#define CONNECT3(__A, __B, __C) __CONNECT3(__A, __B, __C)
#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,_6,_7,_8,_9,__N,...) __N
#define VA_NUM_ARGS(...) \
VA_NUM_ARGS_IMPL(__VA_ARGS__,9,8,7,6,5,4,3,2,1)
#define CONNECT(...) \
CONNECT2(CONNECT, VA_NUM_ARGS(__VA_ARGS__)) \
(__VA_ARGS__)
#define device_write(...) \
CONNECT2(device_write, VA_NUM_ARGS(__VA_ARGS__)) \
(__VA_ARGS__)
void device_write3(int a, int c,int b)
{
printf("33333333\n");
}
void device_write2(int a,int b)
{
printf("22222222\n");
}
void device_write1(int a)
{
printf("11111111\n");
}
int main(int argc,char* argv[])
{
device_write(1,2,3);
device_write(1,2);
device_write(1);
return 0;
}
运行结果: