On Sat, 17 Dec 2022, LIU Hao wrote:

在 2022-12-17 20:01, Pali Rohár 写道:
It would be nice if somebody who understand these patterns write some
comment what is the real purpose of the first __pctype_func() definition
because for me it looks like a dead code. And this pattern is repeated
multiple times in lot of other header files.

If we look at 'apisetcconv.h' we can find similiar patterns as well, such as:

  ```
  #ifndef WINUSERAPI
  #ifndef _USER32_
  #define WINUSERAPI DECLSPEC_IMPORT
  #else
  #define WINUSERAPI
  #endif
  #endif
  ```

There is no static library for USER32.DLL, so all USER32 functions are always `DECLSPEC_IMPORT`. So, when is `WINUSERAPI` defined empty? I suspect it's only effective when building USER32.DLL itself by Microsoft.

I guess so too.

For the purposes of mingw-w64 headers, I guess these stem from trying to match more details of Microsoft headers than strictly necessary. And with the potential use cases of mingw-w64, it's essentially dead code.

I would be fine with removing such cases from our headers as we don't have any practical way of testing those codepaths anyway - especially for cases where it can get in the way (like for those CRT headers - while the quoted one from apisetcconv.h seems harmless). In particular for CRT headers, where there are multiple alternatives for what DLL to interact with, those ifdefs are kinda problematic to fix right (unless you just do what's been done so far - ignore that ifdef branch entirely).

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to