On Mon, 8 Jan 2024, Antonin Décimo wrote:
Thanks for all the pointers! I would have expected that users needed to define
_WIN32_WINNT to an old value for these targets.
Yes, that's one reasonable point of view - but there seems to be some
demand for default toolchain builds to be able to target these, especially
when the amount of extra effort needed to support it is pretty small.
If I understand correctly, the issue with MSVC here is only about not
supporting __attribute__((constructor)).
Indeed.
It should be possible to achieve the same by storing a pointer to a function
in the suitable .CRT$XC? section.
Do you mean with something as documented in [CRT Initialization][1]?
How would that work in C?
Yes, pretty much.
It should be pretty straightforward - something like this:
#include <corecrt_startup.h>
static void myctor(void) {
printf("ctor\n");
}
#pragma section(".CRT$XCT",long,read)
__declspec(allocate(".CRT$XCT")) _PVFV ptr = myctor;
Compared to the mingw case, just skip the __attribute__((constructor)),
and declare this extra pointer to the function, to trigger it to be
executed.
It seems that the pattern would exactly be covered by using
pthread_once [2]. Could we use that instead?
I would prefer not to. Within a library implementing pthread functions, I
would want to avoid using pthreads for initializing the library.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public