zeux/volk

Compile error with MinGW cross-compiler

ceeac opened this issue · 2 comments

ceeac commented

Platform: Ubuntu 22.04
Compiler: MinGW-w64 GCC 10 cross-compiler

When windows.h is included before volk.h (e.g. when glad is used), compilation fails with the following error:

deps/volk/volk.c:10:31: error: redefinition of typedef ‘FARPROC’ with different type
   10 |   typedef __int64 (__stdcall* FARPROC)(void);
      |                               ^~~~~~~
In file included from /usr/share/mingw-w64/include/windef.h:9,
                 from /usr/share/mingw-w64/include/windows.h:69,
                 from deps/glad/include/glad/vulkan.h:342,
<snip...>
/usr/share/mingw-w64/include/minwindef.h:196:28: note: previous declaration of ‘FARPROC’ was here
  196 |   typedef INT_PTR (WINAPI *FARPROC) ();
      |                            ^~~~~~~

The minwindef.h Windows header also contains the latter declaration, so I assume the non-void parameter declaration is the correct one.

zeux commented

Interesting; I can reproduce this, but this used to use () argument list and was changed to (void) in #23.

Indeed, fixing this but compiling with -Wstrict-prototypes produces:

volk.c:12:17: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
   12 |                 typedef int (__stdcall* FARPROC)();
      |                 ^~~~~~~

In your case, I am assuming the issue only happens in the translation unit that defines VOLK_IMPLEMENTATION?

ceeac commented

In your case, I am assuming the issue only happens in the translation unit that defines VOLK_IMPLEMENTATION?

Yes.