This is the mail archive of the
mailing list for the GCC project.
Re: Dealing with compilers that pretend to be GCC
On Jan 31, 2012, at 5:15 AM, Ludovic Courtès wrote:
>> Interestingly enough:
>> $ cat q.c
>> $ clang -E q.c
> 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:
#define __has_builtin(x) 0
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.