1.
#define Conn(x,y) x##y#define ToChar(x) #define ToString(x) #xx##y表示什么?表示x连接y,举例说:int n = Conn(123,456); 结果就是n=123456;char* str = Conn("asdf", "adf")结果就是 str = "asdfadf";再来看,其实就是给x加上单引号,结果返回是一个const char。举例说:char a = ToChar(1);结果就是a='1';做个越界试验char a = ToChar(123);结果是a='3';但是如果你的参数超过四个字符,编译器就给给你报错了!error C2015: too many characters in constant :P最后看看#x,估计你也明白了,他是给x加双引号char* str = ToString(123132);就成了str="123132";最后留几个小试验给大家去测测:#define Dec(x,y) (x-y)int n = Dec( A(123,1), 1230);n = Conn(123, Conn(123,332) );char* str = A("12", ToString( Dec(3,1));
2.
#define log(...) printf(__VA_ARGS__)
http://blog.csdn.net/zanget/article/details/4556447
void uart_printf(const char *fmt, ...);
#define MAX_MY_SPRINTF 500
char my_sprintf_buf[MAX_MY_SPRINTF];#define PRINT(...) uart_printf(__VA_ARGS__)#define FL_PRINT(...) uart_printf(__VA_ARGS__),uart_printf(",%s %d %s",__FILE__,__LINE__,__func__)#define SPRINTF(buf,...) sprintf(buf+strlen(buf),__VA_ARGS__),\ sprintf(buf+strlen(buf),",%s %d %s",__FILE__,__LINE__,__func__),buf[MAX_MY_SPRINTF - 1]=0