On Jan 31, 2012, at 5:15 AM, Ludovic Courtès wrote: >> >> Interestingly enough: >> $ cat q.c >> __has_builtin >> $ clang -E q.c >> <segfault> > > Yes, that’s what I was asking. > > It makes me think that the old CPP predicates (info "(gcc) Obsolete > Features") would be more appropriate than compiler magic, with the > caveat that they’re presumably not widely supported.
They are similar in spirit. The major difference between the two is that it is easy for __has_feature and friends gracefully degrade when a compiler doesn't support them, because you can do: #ifndef __has_builtin #define __has_builtin(x) 0 #endif in your code, but you can't do anything like this for #assertion. That and assertions don't have any coverage over the features that you're interested in, and the grammar doesn't have a good way to handle multiple cases like features/attributes/extensions/etc. -Chris