0

I just downloaded llvm-11-win64 from official llvm website (I need to use clang instead of mingw-g++). I'm trying to compile a test C++ file that includes <windows.h> (the header files are taken from a mingw64 install)

// test.cpp
#include <windows.h>

bool WINAPI DllMain(HINSTANCE hModule, DWORD fwdReason, LPVOID reserved)
{
    return TRUE;
}

Typical command line compilation gives an error, should I do something different?

$ clang++ -I "/c/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/" -c test.cpp
In file included from test.cpp:2:
In file included from C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include\windows.h:69:
In file included from C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include\windef.h:8:
In file included from C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include\minwindef.h:163:
In file included from C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include\winnt.h:1554:
In file included from C:\Program Files\LLVM\lib\clang\11.0.0\include\x86intrin.h:15:
In file included from C:\Program Files\LLVM\lib\clang\11.0.0\include\immintrin.h:15:
C:\Program Files\LLVM\lib\clang\11.0.0\include\mmintrin.h:67:40: error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 * sizeof(int)))) int'
      (vector of 2 'int' values) with an rvalue of type '__v2si' (aka 'int')
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
                                       ^~~~~~~~~~~
melkyades
  • 1,719
  • 11
  • 20

1 Answers1

0

the header files are taken from a mingw64 install

Microsoft provides the official Windows headers which work with Clang (if I am not mistaken, Microsoft started providing Clang in Visual Studio a while ago).

Acorn
  • 24,970
  • 5
  • 40
  • 69
  • Yes, but for that I'd need a full blown Visual Studio (which I'd like to avoid) – melkyades Dec 29 '20 at 23:25
  • 1
    Or Windows 10 SDK [https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/) – Daniel Sęk Dec 30 '20 at 07:47