`_m_prefetchw` type signature mismatch on Windows

Hi,

I was compiling `sqlite3.c` via Zig a while ago and noticed a type mismatch between the Windows headers and the LLVM headers that Zig ships with.

The Windows header `mm3dnow.h` declares it as:

     void _m_prefetchw(volatile const void*_Source);

Whereas the LLVM header `clang\lib\Headers\prfchwintrin.h` declares:

     static __inline__ void __attribute__((__always_inline__, __nodebug__))
     _m_prefetchw(volatile const void *__P) {
       __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
     }

`__builtin_prefetch`, which `_m_prefetchw` is using, is defined as taking `const void*` at the moment.

The mismatch effectively causes the function to have two different signatures when compiling C source in Zig on Windows. The most direct change is to modify the shipped Zig headers, but it'd be interesting to see this fixed at the source.

Is there any major issue with `ifdef`ing a solution when using MSVC that anyone can see?

With regards,
Rickard Andersson

If clang is finding MSVC's mm3dnow.h instead of its own, you've misconfigured the include paths. clang should always use its own version.

-Eli

Hi again,

It turns out I was mistaken about the source of the error. I've made a paste with the error I'm running into instead; it comes from a redeclaration (still in a Windows header, but in one of the Windows Kits):

https://bpa.st/5PSA

`sqlite3.c` includes `windows.h` and it seems that perhaps there is an IFDEF lacking somewhere that causes `winnt.h` to redeclare `_m_prefetchw`.

Is it in the scope of clang/LLVM to address this?

// Rickard

"llvm-dev@lists.llvm.org" <llvm-dev@lists.llvm.org>
Windows

If it's in the Windows SDK headers, it's something we want to address, yes. See https://reviews.llvm.org/D24330 . (I guess the set of intrinsics used by winnt.h changed since the last time someone looked.)

-Eli