paullouisageneau / libjuice

JUICE is a UDP Interactive Connectivity Establishment library
Mozilla Public License 2.0
432 stars 82 forks source link

Warnings when cross-compiling #260

Closed fatduckling closed 4 months ago

fatduckling commented 4 months ago

Hi I'm using mingw compiler on Debian to cross-compile juice to windows. I'm seeing the following warnings:

...
[ 85%] Building C object CMakeFiles/juice.dir/src/turn.c.obj
[ 90%] Building C object CMakeFiles/juice.dir/src/udp.c.obj
[ 95%] Building C object CMakeFiles/juice.dir/src/timestamp.c.obj
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/log.c:10:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:272: CMakeFiles/juice.dir/src/log.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/random.c:11:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:287: CMakeFiles/juice.dir/src/random.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.c:9:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:137: CMakeFiles/juice.dir/src/conn.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/udp.c:13:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:362: CMakeFiles/juice.dir/src/udp.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_poll.h:13,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_poll.c:9:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:152: CMakeFiles/juice.dir/src/conn_poll.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_thread.h:13,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_thread.c:9:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:167: CMakeFiles/juice.dir/src/conn_thread.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_mux.h:13,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn_mux.c:9:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:182: CMakeFiles/juice.dir/src/conn_mux.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/agent.h:13,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/juice.c:11:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:257: CMakeFiles/juice.dir/src/juice.c.obj] Error 1
In file included from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/conn.h:14,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/agent.h:13,
                 from /tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/agent.c:9:
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h: In function 'thread_set_name_self':
/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/src/thread.h:114:29: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(void *, const WCHAR *)' {aka 'long int (*)(void *, const short unsigned int *)'} [-Werror=cast-function-type]
  114 |                             (pfnSetThreadDescription)GetProcAddress(kernel32, "SetThreadDescription");
      |                             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/juice.dir/build.make:92: CMakeFiles/juice.dir/src/agent.c.obj] Error 1
make[2]: Leaving directory '/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/build_WINDOWS_X86_64'
make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/juice.dir/all] Error 2
make[1]: Leaving directory '/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/build_WINDOWS_X86_64'
make: *** [Makefile:136: all] Error 2
make: Leaving directory '/tmp/93351f1ab8597e75f5032a550fef65e991d8a4bf/build_WINDOWS_X86_64'

I've tried Android, iOS, OSX cross-compilers on Debian and they didn't produce these warnings. It's only for Windows cross-compilation they're appearing.

Thanks

paullouisageneau commented 4 months ago

This is expected, you need to perform that cast when invoking GetProcAddress() on Windows. The best you can do here is ignore the warning. If you want you can disable it in CMakeLists.txt to be able to compile with warnings as errors.