what's the help of "unnecessary" pointer comparison

引述自http://c-programming.itags.org/q_c-programming-language_191518.html

源代码中的宏min中使用了

 (void) (&_x == &_y); 

(   c89不支持typeof   )

有如下解释

Assuming (as the name "typeof" implies) that _x has the same type as

x, and _y has the same type as y, comparing the addresses of _x and _y

is legal if and only if they have the same type. The result of the

comparison is irrelevant (and it's discarded anyway); the point is to

force the compiler to reject an invocation of the macro if the

arguments' types don't match. 

posted on 2013-08-07 14:37  阿加  阅读(318)  评论(0编辑  收藏  举报

导航