<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - VS C++ errors for compiler.h"
   href="https://bugs.llvm.org/show_bug.cgi?id=40673">40673</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>VS C++ errors for compiler.h
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Support Libraries
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hans.petter.dahle@hpdahle.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When including the header file '\llvm\Support\Compiler.h',
Visual Studio's C++ compiler (used from Visual Studio Community 2017) complains
that there are 3 errors in this header file, on lines 127, 230, and 236.

The error message is:
E2512   the argument to a feature-test macro must be a simple identifier

The cause of these error messages is the use of "::" in the argument to
'__has_cpp_attribute'.

My proposal is to wrap each erroneous line and the line following it in a test
to check whether '_MSC_VER' is defined or not. 

E.g. lines 127 and 128 which are 

#elif __has_cpp_attribute(clang::warn_unused_result)
#define LLVM_NODISCARD [[clang::warn_unused_result]]

should be changed to    

#elif !defined(_MSC_VER) 
#if __has_cpp_attribute(clang::warn_unused_result)
#define LLVM_NODISCARD [[clang::warn_unused_result]]
#endif

This change fixes the error for me.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>