Compilation error w/ MSYS2 GCC: Incompatible pointer types
takase1121 opened this issue · 5 comments
Compiler Error
[126/135] Building C object lib/CMakeFiles/zip.dir/zip_source_file_win32_ansi.c.obj
FAILED: lib/CMakeFiles/zip.dir/zip_source_file_win32_ansi.c.obj
E:\msys64\ucrt64\bin\cc.exe -DWIN32_LEAN_AND_MEAN -IE:/msys64/home/takas/libzip/lib -IE:/msys64/home/takas/libzip/build -fvisibility=hidden -MD -MT lib/CMakeFiles/zip.dir/zip_source_file_win32_ansi.c.obj -MF lib\CMakeFiles\zip.dir\zip_source_file_win32_ansi.c.obj.d -o lib/CMakeFiles/zip.dir/zip_source_file_win32_ansi.c.obj -c E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:44:5: error: initialization of 'void * (*)(const void *, DWORD, DWORD, struct _SECURITY_ATTRIBUTES *, DWORD, DWORD, void *)' {aka 'void * (*)(const void *, long unsigned int, long unsigned int, struct _SECURITY_ATTRIBUTES *, long unsigned int, long unsigned int, void *)'} from incompatible pointer type 'void * (*)(const CHAR *, DWORD, DWORD, struct _SECURITY_ATTRIBUTES *, DWORD, DWORD, void *)' {aka 'void * (*)(const char *, long unsigned int, long unsigned int, struct _SECURITY_ATTRIBUTES *, long unsigned int, long unsigned int, void *)'} [-Wincompatible-pointer-types]
44 | CreateFileA,
| ^~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:44:5: note: (near initialization for 'ops_ansi.create_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:45:5: error: initialization of 'BOOL (*)(const void *)' {aka 'int (*)(const void *)'} from incompatible pointer type 'WINBOOL (*)(const CHAR *)' {aka 'int (*)(const char *)'} [-Wincompatible-pointer-types]
45 | DeleteFileA,
| ^~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:45:5: note: (near initialization for 'ops_ansi.delete_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:46:5: error: initialization of 'DWORD (*)(const void *)' {aka 'long unsigned int (*)(const void *)'} from incompatible pointer type 'DWORD (*)(const CHAR *)' {aka 'long unsigned int (*)(const char *)'} [-Wincompatible-pointer-types]
46 | GetFileAttributesA,
| ^~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:46:5: note: (near initialization for 'ops_ansi.get_file_attributes')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:47:5: error: initialization of 'BOOL (*)(const void *, GET_FILEEX_INFO_LEVELS, void *)' {aka 'int (*)(const void *, GET_FILEEX_INFO_LEVELS, void *)'} from incompatible pointer type 'WINBOOL (*)(const CHAR *, GET_FILEEX_INFO_LEVELS, void *)' {aka 'int (*)(const char *, GET_FILEEX_INFO_LEVELS, void *)'} [-Wincompatible-pointer-types]
47 | GetFileAttributesExA,
| ^~~~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:47:5: note: (near initialization for 'ops_ansi.get_file_attributes_ex')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:49:5: error: initialization of 'BOOL (*)(const void *, const void *, DWORD)' {aka 'int (*)(const void *, const void *, long unsigned int)'} from incompatible pointer type 'WINBOOL (*)(const CHAR *, const CHAR *, DWORD)' {aka 'int (*)(const char *, const char *, long unsigned int)'} [-Wincompatible-pointer-types]
49 | MoveFileExA,
| ^~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:49:5: note: (near initialization for 'ops_ansi.move_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:50:5: error: initialization of 'BOOL (*)(const void *, DWORD)' {aka 'int (*)(const void *, long unsigned int)'} from incompatible pointer type 'WINBOOL (*)(const CHAR *, DWORD)' {aka 'int (*)(const char *, long unsigned int)'} [-Wincompatible-pointer-types]
50 | SetFileAttributesA,
| ^~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_ansi.c:50:5: note: (near initialization for 'ops_ansi.set_file_attributes')
[127/135] Building C object lib/CMakeFiles/zip.dir/zip_source_file_win32_utf16.c.obj
FAILED: lib/CMakeFiles/zip.dir/zip_source_file_win32_utf16.c.obj
E:\msys64\ucrt64\bin\cc.exe -DWIN32_LEAN_AND_MEAN -IE:/msys64/home/takas/libzip/lib -IE:/msys64/home/takas/libzip/build -fvisibility=hidden -MD -MT lib/CMakeFiles/zip.dir/zip_source_file_win32_utf16.c.obj -MF lib\CMakeFiles\zip.dir\zip_source_file_win32_utf16.c.obj.d -o lib/CMakeFiles/zip.dir/zip_source_file_win32_utf16.c.obj -c E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:46:5: error: initialization of 'void * (*)(const void *, DWORD, DWORD, struct _SECURITY_ATTRIBUTES *, DWORD, DWORD, void *)' {aka 'void * (*)(const void *, long unsigned int, long unsigned int, struct _SECURITY_ATTRIBUTES *, long unsigned int, long unsigned int, void *)'} from incompatible pointer type 'void * (*)(const char *, DWORD, DWORD, struct _SECURITY_ATTRIBUTES *, DWORD, DWORD, void *)' {aka 'void * (*)(const char *, long unsigned int, long unsigned int, struct _SECURITY_ATTRIBUTES *, long unsigned int, long unsigned int, void *)'} [-Wincompatible-pointer-types]
46 | utf16_create_file,
| ^~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:46:5: note: (near initialization for 'ops_utf16.create_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:47:5: error: initialization of 'BOOL (*)(const void *)' {aka 'int (*)(const void *)'} from incompatible pointer type 'WINBOOL (*)(const WCHAR *)' {aka 'int (*)(const short unsigned int *)'} [-Wincompatible-pointer-types]
47 | DeleteFileW,
| ^~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:47:5: note: (near initialization for 'ops_utf16.delete_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:48:5: error: initialization of 'DWORD (*)(const void *)' {aka 'long unsigned int (*)(const void *)'} from incompatible pointer type 'DWORD (*)(const WCHAR *)' {aka 'long unsigned int (*)(const short unsigned int *)'} [-Wincompatible-pointer-types]
48 | GetFileAttributesW,
| ^~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:48:5: note: (near initialization for 'ops_utf16.get_file_attributes')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:49:5: error: initialization of 'BOOL (*)(const void *, GET_FILEEX_INFO_LEVELS, void *)' {aka 'int (*)(const void *, GET_FILEEX_INFO_LEVELS, void *)'} from incompatible pointer type 'WINBOOL (*)(const WCHAR *, GET_FILEEX_INFO_LEVELS, void *)' {aka 'int (*)(const short unsigned int *, GET_FILEEX_INFO_LEVELS, void *)'} [-Wincompatible-pointer-types]
49 | GetFileAttributesExW,
| ^~~~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:49:5: note: (near initialization for 'ops_utf16.get_file_attributes_ex')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:51:5: error: initialization of 'BOOL (*)(const void *, const void *, DWORD)' {aka 'int (*)(const void *, const void *, long unsigned int)'} from incompatible pointer type 'WINBOOL (*)(const WCHAR *, const WCHAR *, DWORD)' {aka 'int (*)(const short unsigned int *, const short unsigned int *, long unsigned int)'} [-Wincompatible-pointer-types]
51 | MoveFileExW,
| ^~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:51:5: note: (near initialization for 'ops_utf16.move_file')
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:52:5: error: initialization of 'BOOL (*)(const void *, DWORD)' {aka 'int (*)(const void *, long unsigned int)'} from incompatible pointer type 'WINBOOL (*)(const WCHAR *, DWORD)' {aka 'int (*)(const short unsigned int *, long unsigned int)'} [-Wincompatible-pointer-types]
52 | SetFileAttributesW,
| ^~~~~~~~~~~~~~~~~~
E:/msys64/home/takas/libzip/lib/zip_source_file_win32_utf16.c:52:5: note: (near initialization for 'ops_utf16.set_file_attributes')
[130/135] Building C object lib/CMakeFiles/zip.dir/zip_source_file_win32_named.c.obj
ninja: build stopped: subcommand failed.
libzip Version: 81fc708
Operating System and Compiler
OS: Windows 11 22H2 Build 22621
CC: gcc version 14.1.0 (Rev3, Built by MSYS2 project)
CXX: gcc version 14.1.0 (Rev3, Built by MSYS2 project)
Cmake: cmake version 3.29.5
ninja: 1.12.1
Platform: MSYS2 UCRT64
Also, any flags passed to cmake
.
cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_BZIP2=OFF -DENABLE_LZMA=OFF -DENABLE_ZSTD=OFF
Autodetected Configuration
Additional context
This issue is fixed in #375 with 6488a80, but the fix only includes clang. GCC now has the same issue and this is worked around at MSYS2 but not communicated back here.
Thank you for the bug report.
Can you please try this patch?
diff --git a/lib/zip_source_file_win32.h b/lib/zip_source_file_win32.h
index d86069ec..bbd6b9e7 100644
--- a/lib/zip_source_file_win32.h
+++ b/lib/zip_source_file_win32.h
@@ -76,6 +76,9 @@ int _zip_win32_error_to_errno(DWORD win32err);
#ifdef __clang__
#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-function-pointer-types\"")
#define DONT_WARN_INCOMPATIBLE_FN_PTR_END _Pragma("GCC diagnostic pop")
+#elif defined(__GNUC__) && __GNUC__ > 13
+#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-type\"")
+#define DONT_WARN_INCOMPATIBLE_FN_PTR_END _Pragma("GCC diagnostic pop")
#else
#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN
#define DONT_WARN_INCOMPATIBLE_FN_PTR_END
Hi, the patch worked with a minor typo fix:
diff --git a/lib/zip_source_file_win32.h b/lib/zip_source_file_win32.h
index d86069ec..86ef2651 100644
--- a/lib/zip_source_file_win32.h
+++ b/lib/zip_source_file_win32.h
@@ -76,6 +76,9 @@ int _zip_win32_error_to_errno(DWORD win32err);
#ifdef __clang__
#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-function-pointer-types\"")
#define DONT_WARN_INCOMPATIBLE_FN_PTR_END _Pragma("GCC diagnostic pop")
+#elif defined(__GNUC__) && __GNUC__ > 13
+#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types\"")
+#define DONT_WARN_INCOMPATIBLE_FN_PTR_END _Pragma("GCC diagnostic pop")
#else
#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN
#define DONT_WARN_INCOMPATIBLE_FN_PTR_END
Thank you, committed!
After #446 the whole block starting from
libzip/lib/zip_source_file_win32.h
Line 76 in 105e7a8
(and the usages of
DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN/END
)