在 2022/10/9 18:05, Pali Rohár 写道:
Ok, I see. Anyway, I quite do not understand why some crt exported functions are marked with _CRTIMP (as it is empty during CRT build) and some exported variables use __MINGW_IMP_SYMBOL. I would expect that all exported functions and variables (from dll) would use same "syntax" and same "behavior". Is not this a bug? And why is not used directly __desclspec(dllimport)? I think that specifying dllimport is same as using __MINGW_IMP_SYMBOL and then defining a new macro with pointer dereferencing of defined symbol. Or not and is there something special why "more complicated" approach via __MINGW_IMP_SYMBOL is required?
Because sometimes we would like to override them, for example, in
'ucrtbase_compat.c'.
This
```
void __attribute__((__dllimport__)) _tzset(void);
void (*__imp__tzset)(void) = _tzset;
int
main(void)
{
_tzset();
}
```
will cause an error, as the function call to dllimport'd function in `main()` pulls it from
'libmsvcrt.a', which also brings its own pointer:
``` $ x86_64-w64-mingw32-gcc -Wall -Wextra test.c /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-w in32/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a(libmsvcrt-oss007 17.o):(.idata$5+0x0): multiple definition of `__imp__tzset'; /tmp/cc 1GlQ7e.o:test.c:(.data+0x0): first defined here collect2: error: ld returned 1 exit status ```
Please do not take me wrong (for maybe stupid questions), I'm just trying to understand how it works and why it is written in this way.
Of course not. :) -- Best regards, LIU Hao
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
