My advice on implementing stuff in C:
My advice on implementing stuff in C:
Posted Oct 18, 2010 22:43 UTC (Mon) by foom (subscriber, #14868)In reply to: My advice on implementing stuff in C: by cmccabe
Parent article: Russell: On C Library Implementation
The linux kernel is not written in C: it is written in an extended GCC-proprietary C variant.
>> #define min(x, y) ({ \
({ is a GCC extension (statement-expression), it is not in C.
>> typeof(x) _min1 = (x); \
>> typeof(y) _min2 = (y); \
typeof is a GCC extension, it is not in C.
>> (void) (&_min1 == &_min2); \
Comparison of distinct pointer types is not an error in C.
>> _min1 < _min2 ? _min1 : _min2; })
>I'm getting a little tired of being told what I can't do, especially when it turns out that I can do it after all.
Just because you can do it in GCC, doesn't mean you can do it in C.
