B
baumann@pan
hi all,
i could not understand the "unnecessary" pointer comparison.
/*
207 * min()/max() macros that also do
208 * strict type-checking.. See the
209 * "unnecessary" pointer comparison.
210 */
211 #define min(x,y) ({ \
212 typeof(x) _x = (x); \
213 typeof(y) _y = (y); \
214 (void) (&_x == &_y); \
215 _x < _y ? _x : _y; })
216
217 #define max(x,y) ({ \
218 typeof(x) _x = (x); \
219 typeof(y) _y = (y); \
220 (void) (&_x == &_y); \
221 _x > _y ? _x : _y; })
222
what's the meaing of line 214 and line 220?
IMHO, the result of the 2 is always FALSE. since &_x is the address of
loccal variable _x and &_y is the address of local variable _y.
so I can not figure out the meaning of "unnecessary" pointer
comparison.
anyone could explain it for me? TIA.
baumann@pan
i could not understand the "unnecessary" pointer comparison.
/*
207 * min()/max() macros that also do
208 * strict type-checking.. See the
209 * "unnecessary" pointer comparison.
210 */
211 #define min(x,y) ({ \
212 typeof(x) _x = (x); \
213 typeof(y) _y = (y); \
214 (void) (&_x == &_y); \
215 _x < _y ? _x : _y; })
216
217 #define max(x,y) ({ \
218 typeof(x) _x = (x); \
219 typeof(y) _y = (y); \
220 (void) (&_x == &_y); \
221 _x > _y ? _x : _y; })
222
what's the meaing of line 214 and line 220?
IMHO, the result of the 2 is always FALSE. since &_x is the address of
loccal variable _x and &_y is the address of local variable _y.
so I can not figure out the meaning of "unnecessary" pointer
comparison.
anyone could explain it for me? TIA.
baumann@pan