GmSSL icon indicating copy to clipboard operation
GmSSL copied to clipboard

MinGW 下也跟 MSVC 一样导出所有符号,修复链接错误

Open driver1998 opened this issue 2 months ago • 1 comments

MSYS2 UCRT64 环境(GCC 13.2.0 + MinGW + Universal CRT)下测试通过。

Fixes https://github.com/guanzhi/GmSSL/issues/1600, https://github.com/guanzhi/GmSSL/issues/1575

driver1998 avatar Apr 22 '24 08:04 driver1998

https://github.com/guanzhi/GmSSL/blob/bdd2149dc886cab5039d45c5bcfa950e287e2650/tools/tlcp_client.c#L251-L281

此处的 _fileno 我找不到对应的变量定义,编译时似乎是指向了 Windows 的 _fileno 函数,于是触发了函数指针强转为 SOCKET (UINT_PTR) 的问题,这在 GCC 上是 warning,Clang 上是 error。

附 Clang 下的报错信息

FAILED: CMakeFiles/gmssl-bin.dir/tools/tlcp_client.c.obj
D:\msys64\clang64\bin\cc.exe -DENABLE_ASM_UNDERSCORE_PREFIX -DENABLE_SHA2 -D_WINSOCK_DEPRECATED_NO_WARNINGS -ID:/Projects/GmSSL/include  -MD -MT CMakeFiles/gmssl-bin.dir/tools/tlcp_client.c.obj -MF CMakeFiles\gmssl-bin.dir\tools\tlcp_client.c.obj.d -o CMakeFiles/gmssl-bin.dir/tools/tlcp_client.c.obj -c D:/Projects/GmSSL/tools/tlcp_client.c
D:/Projects/GmSSL/tools/tlcp_client.c:258:4: warning: comparison between pointer and integer ('SOCKET' (aka 'unsigned long long') and 'int (*)(FILE *) __attribute__((cdecl))' (aka 'int (*)(struct _iobuf *)')) [-Wpointer-integer-compare]
  258 |                         FD_SET(_fileno, &fds);
      |                         ^~~~~~~~~~~~~~~~~~~~~
D:/msys64/clang64/include/psdk_inc/_fd_types.h:77:40: note: expanded from macro 'FD_SET'
   77 |                 if (((fd_set *)(set))->fd_array[__i] == (fd)) {         \
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
D:/Projects/GmSSL/tools/tlcp_client.c:258:4: error: incompatible pointer to integer conversion assigning to 'SOCKET' (aka 'unsigned long long') from 'int (FILE *) __attribute__((cdecl))' (aka 'int (struct _iobuf *)') [-Wint-conversion]
  258 |                         FD_SET(_fileno, &fds);
      |                         ^~~~~~~~~~~~~~~~~~~~~
D:/msys64/clang64/include/psdk_inc/_fd_types.h:83:37: note: expanded from macro 'FD_SET'
   83 |                         ((fd_set *)(set))->fd_array[__i] = (fd);        \
      |                                                          ^ ~~~~
1 warning and 1 error generated.
ninja: build stopped: subcommand failed.

请问这真的符合意图吗?目前我不敢动,测试好像也没测到这一块。

driver1998 avatar Apr 22 '24 08:04 driver1998