实现如下——
#define __typecheck(x, y) \
(!!(sizeof((typeof(x)*)1 == (typeof(y)*)1)))
#define __is_constant(x) \
(sizeof(int) == sizeof(*(1 ? ((void*)((long)(x) * 0l)) : (int*)1)))
#define __no_side_effects(x, y) \
(__is_constant(x) && __is_constant(y))
#define __safe_cmp(x, y) \
(__typecheck(x, y) && __no_side_effects(x, y))
#define __cmp(x, y, op)((x) op (y) ? (x) : (y))
#define __cmp_once(x, y, op) ({\
typeof(x) __x = (x);\
typeof(y) __y = (y);\
__cmp(__x, __y, op); })
#define __careful_cmp(x, y, op)\
__builtin_choose_expr(__safe_cmp(x, y),\
__cmp(x, y, op), __cmp_once(x, y, op))
#define max(x, y)__careful_cmp(x, y, >)
#define __typecheck(x, y) \
(!!(sizeof((typeof(x)*)1 == (typeof(y)*)1)))
#define __is_constant(x) \
(sizeof(int) == sizeof(*(1 ? ((void*)((long)(x) * 0l)) : (int*)1)))
#define __no_side_effects(x, y) \
(__is_constant(x) && __is_constant(y))
#define __safe_cmp(x, y) \
(__typecheck(x, y) && __no_side_effects(x, y))
#define __cmp(x, y, op)((x) op (y) ? (x) : (y))
#define __cmp_once(x, y, op) ({\
typeof(x) __x = (x);\
typeof(y) __y = (y);\
__cmp(__x, __y, op); })
#define __careful_cmp(x, y, op)\
__builtin_choose_expr(__safe_cmp(x, y),\
__cmp(x, y, op), __cmp_once(x, y, op))
#define max(x, y)__careful_cmp(x, y, >)

