1
NSArray* arr = [NSArray array];
int a = MIN([arr count], 1); // 0 correct
int b = MIN(0 - 1, 1); // -1 correct
int c = MIN([arr count] - 1, 1); // 1 WRONG
這是MIN宏的定義,在NSObjCRuntime.h:我不明白MIN(a,b)宏中的這種奇怪的行爲。幫幫我?
#if !defined(MIN)
#define MIN(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
#endif
ahhhh ...被類型燒燬。 :) – lawrence 2009-12-28 20:51:21