Incoming type:
#define min_t(type,x,y) \
({ \
type __x = (x); \
type __y = (y); \
__x < __y ? __x:__y;/* 结果返回 */ \
})
No incoming type:
#define min(x,y) \
({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); /* 检查类型是否一致 */\
_x < _y ? _x : _y; /* 返回结果 */ \
})
Function name prints:
void test(){
printf("this is function:%s\n", __FUNCTION__);
}
/* 执行结果打印 this is function:test */
do{} while(0) statement macro:
#define SAFE_FREE(p) \
do{ \
if(p == NULL) break; \
free(p); \
p = NULL; \
}while(0)
goto statement: It is easier to handle errors in the main application scenarios.