The following example will use typeof to build generic macro.
(void) (&_min2 == &_min2); // create compile warning when type is not match.
#define min(x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; })
Branch prediction:
likely macro!!
There are many optimization extensions in the article!
Reference:
Advertisements
Filed under: programming | 2 Comments »