On Mon, 3 May 2021, Christian Franke wrote:

Would plain '... = 0' without cast also work ? IIRC it should since C89 :-)

That doesn't work either - clang seems to consider the cast (either implicit or explicit) between a integer or pointer-to-integer and a pointer-to-function as something which isn't a compile time constant, in this context...

Alternative: Leave '/* = 0 */' only as a comment. There is no need to set a static variable to 0.

That would work.

But the overall question remains - we don't really require a C11 compiler for this yet, so use of that kind of atomics is a bit odd overall. If we use it, I think we should have to bump the requirement by explicitly building with -std=gnu11 or something like that. If we go that way, I think we should use C11 atomics for all of it, i.e. replace InterlockedCompareExchangePointer with a C11 equivalent.

Or go the other way, and use Interlocked* for both reads and updates of it (and then the variable itself doesn't need to be declared _Atomic, afaik).

Or just skip that aspect altogether and just blindly update the pointer variable; that's what's done in every existing case of GetProcAddress lazy loading in mingw-w64-crt.

// 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