Opened 5 years ago
Closed 5 years ago
#1865 closed defect (fixed)
error: cast between incompatible function types from 'FARPROC' on MinGW
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | other | Version: | 1.17.x |
Keywords: | Cc: | ||
uname -a: | MINGW64_NT-10.0 2.11.1(0.329/5/3) x86_64 | ||
nginx -V: | 1.17.3 |
Description
Problem:
https://groonga.org bundles nginx to provide http server, it builds bundled nginx 1.17.3 with MinGW.
https://github.com/groonga/groonga/commit/091fba777241c793b3b3eff582fb64fdb9a74a57/checks
During executing recent CI, it reports error.
Actual:
2019-10-07T01:05:15.7349316Z cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I/d/a/groonga/groonga/include -I/d/a/groonga/groonga/include -DNGX_HTTP_GROONGA_LOG_PATH=\""/mingw64/var/log/groonga/httpd/groonga.log"\" -DNGX_HTTP_GROONGA_QUERY_LOG_PATH=\""/mingw64/var/log/groonga/httpd/groonga-query.log"\" -I src/core -I src/event -I src/event/modules -I src/os/win32 -I objs \ 2019-10-07T01:05:15.7361486Z -o objs/src/os/win32/ngx_win32_init.o \ 2019-10-07T01:05:15.7376066Z src/os/win32/ngx_win32_init.c error: cast between incompatible function types from 'FARPROC'
This error is similar to #1546, but occurred place is different.
2019-10-07T01:05:16.3986206Z src/os/win32/ngx_win32_init.c: In function 'ngx_os_init': 2019-10-07T01:05:16.4540987Z src/os/win32/ngx_win32_init.c:243:15: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(struct pollfd *, ULONG, INT)' {aka 'int (*)(struct pollfd *, long unsigned int, int)'} [-Werror=cast-function-type] 2019-10-07T01:05:16.4695725Z WSAPoll = (ngx_wsapoll_pt) GetProcAddress(hmod, "WSAPoll"); 2019-10-07T01:05:16.4715602Z ^ 2019-10-07T01:05:16.4717443Z cc1.exe: all warnings being treated as errors
Expected:
build succeeds without error.
Addtional Information:
2019-10-07T00:48:02.4678733Z + MINGW64_NT-10.0 2.11.1(0.329/5/3) x86_64 2019-10-07T00:48:02.5551913Z + using GNU C compiler 2019-10-07T00:48:02.6050959Z + gcc version: 8.2.0 (Rev1, Built by MSYS2 project) 2019-10-07T00:48:02.7918999Z checking for gcc -pipe switch ... found 2019-10-07T00:48:02.8123895Z checking for MINGW64_NT-10.0 specific features 2019-10-07T00:48:03.1517890Z configuring additional modules
Attachments (1)
Change History (4)
by , 5 years ago
Attachment: | 1_Build.txt.gz added |
---|
comment:1 by , 5 years ago
Thanks for the report. It looks like gcc fails to handle normal GetProcAddress()
usage on Windows, and issues a clearly wrong warning on casts between function types it thinks are not compatible. The following patch should fix this:
# HG changeset patch # User Maxim Dounin <mdounin@mdounin.ru> # Date 1571170186 -10800 # Tue Oct 15 23:09:46 2019 +0300 # Node ID 7a2e380f0eb74c84d9e8f58719d15cb348b4e1dc # Parent be5858ead6d61339441fb1ef8eb684cef0458b74 Win32: silenced -Wcast-function-type GCC warning (ticket #1865). With MinGW-w64, building 64-bit nginx binary with GCC 8 and above results in warning due to cast of GetProcAddress() result to ngx_wsapoll_pt, which GCC thinks is incorrect. Added intermediate cast to "void *" to silence the warning. diff -r be5858ead6d6 -r 7a2e380f0eb7 src/os/win32/ngx_win32_init.c --- a/src/os/win32/ngx_win32_init.c Fri Oct 11 16:15:32 2019 +0300 +++ b/src/os/win32/ngx_win32_init.c Tue Oct 15 23:09:46 2019 +0300 @@ -240,7 +240,7 @@ ngx_os_init(ngx_log_t *log) goto nopoll; } - WSAPoll = (ngx_wsapoll_pt) GetProcAddress(hmod, "WSAPoll"); + WSAPoll = (ngx_wsapoll_pt) (void *) GetProcAddress(hmod, "WSAPoll"); if (WSAPoll == NULL) { ngx_log_error(NGX_LOG_NOTICE, log, ngx_errno, "GetProcAddress(\"WSAPoll\") failed");
Note:
See TracTickets
for help on using tickets.
CI build log (compressed)