在 2024-09-23 18:48, Martin Storsjö 写道:
Well, as Liu Hao showed, using (void*) casts can get warned about, if we compile it with all available warning flags. But we don't build mingw-w64-crt that way.Anyway, Liu Hao, you mentioned that you wanted to try to touch up this patch in some way (moving some declaration into a header or similar), feel free to pick it up and do that. Or should we go with it as is, or with a simpler void* which is fine given how mingw-w64-crt is compiled in practice, or intptr_t?
We currently have three options: 1. Cast the result from `GetProcAddress()` once to `void*`, and let it convert to the target type implicitly. 2. Double-cast the result via `void (*)(void)`. 3. Double-cast the result via `intptr_t`. Jacek is suggesting 1, this patch does 2, and my previous suggestion was 3.My concern is that if today a compiler starts to warn about casts between incompatible function pointers (which are perfectly okay though), then someday it may start to warn about implicit conversions between `void*` and function pointers, and we will have to patch these casts again.
2 is the standard solution, but it looks verbose. I suggest that we move the `_PVFV` typedef to a common header, and reuse it.
3 is my first suggestion. As with 1 it works in practice, and I believe it shouldn't cause warnings in reasonable future.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public