<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Am 06.05.15 um 14:21 schrieb Aaron
      Ballman:<br>
    </div>
    <blockquote
cite="mid:CAAt6xTsSLE10vG_7U5ek4m132Ks8EgtnvUt1gM8jSmsU8q3ipg@mail.gmail.com"
      type="cite">
      <pre wrap="">On Wed, May 6, 2015 at 4:28 AM, Kal <a class="moz-txt-link-rfc2396E" href="mailto:b17c0de@gmail.com"><b17c0de@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi,
The following seems like a clang bug.

You can't use __has_cpp_attribute with namespaces in a header that is
included from C. For example:
#if __has_cpp_attribute(clang::fallthrough)
   ...
#endif

Yields:
error: builtin feature check macro requires a parenthesized identifier.

Shouldn't __has_cpp_attribute() evaluate to 0 for C programs?
</pre>
      </blockquote>
      <pre wrap="">
That's debatable. I would say it should be an error for C programs to
refer to __has_cpp_attribute because it should not be a predefined
macro there. I think the bug is that __has_cpp_attribute isn't flag as
being available only for C++. Then you could use the canonical
#if/#elif block for C++ attribute feature testing, without needing the
__cplusplus bit in yours.

~Aaron</pre>
    </blockquote>
    <br>
    From claim documentation for __has_cpp_attribute: "
    <meta charset="utf-8">
    <span style="color: rgb(51, 51, 51); font-family: 'DejaVu Sans',
      Arial, Helvetica, sans-serif; font-size: 14.3999996185303px;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 21.6000003814697px; orphans:
      auto; text-align: justify; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 1; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; display: inline !important; float:
      none; background-color: rgb(255, 255, 255);">If the attribute is
      not supported by the current compliation target, this macro
      evaluates to 0."</span> No C++ attributes are supported when
    compiling for C, so shouldn't they just all return 0? If
    __has_cpp_attribute wasn't defined at all for C programs that would
    also be good. Either way, what clang does now seems broken.<br>
    <br>
    <blockquote
cite="mid:CAAt6xTsSLE10vG_7U5ek4m132Ks8EgtnvUt1gM8jSmsU8q3ipg@mail.gmail.com"
      type="cite">
      <pre wrap="">

</pre>
      <blockquote type="cite">
        <pre wrap="">
I worked around the issue with something like:

#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#elif defined(__clang__) && !defined(__cplusplus)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbuiltin-macro-redefined"
#define __has_cpp_attribute(x) 0
#pragma clang diagnostic pop
#endif

Is there a better way?

-Kal
_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>