[cfe-dev] magic __has_feature macro

Makslane Araújo Rodrigues makslane at hotmail.com
Sat Jun 13 04:20:15 PDT 2009


Great idea, Chris!

> From: clattner at apple.com
> To: eli.friedman at gmail.com
> Date: Fri, 12 Jun 2009 22:44:18 -0700
> CC: cfe-dev at cs.uiuc.edu
> Subject: Re: [cfe-dev] magic __has_feature macro
> 
> 
> On Jun 12, 2009, at 6:18 PM, Eli Friedman wrote:
> 
> > On Fri, Jun 12, 2009 at 6:03 PM, Chris Lattner<clattner at apple.com>  
> > wrote:
> >> Hi All,
> >>
> >> As Clang "grows up", it will continue to get more features.  I'd like
> >> to add new "__has_feature" builtin function-like macro that evaluates
> >> to 0 or 1 if clang has a specified feature.
> >
> > What does it evaluate to if clang doesn't have the specified  
> > feature? :)
> 
> haha. :)
> 
> > Sounds like a good idea.
> 
> Ok, my proposed use of if defined won't work because of the parsing  
> structure of pp conditionals.  However, something like this will work:
> 
> #ifndef __has_feature
> #define __has_feature(x) 0
> #endif
> 
> // ...
> 
> #if __has_feature(x)
>   ... whatever ...
> #endif
> 
> 
> I also plan to add a __has_builtin(x) as well, so that we can write  
> things like:
> 
> #if __has_builtin(__builtin_trap)
>    __builtin_trap();
> #else
>    abort();
> #endif
> 
> Look, no autoconf, and no fragile compiler version checks! :)
> 
> I'll start working on this.
> 
> -Chris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_________________________________________________________________
Descubra todas as novidades do novo Internet Explorer 8
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090613/9ce4caa2/attachment.html>


More information about the cfe-dev mailing list