> I don't get your point. Microsoft winnt.h has a dependency on non-builtin > target-identification macros such as `_AMD64_` which are defined by windows.h, so including winnt.h without windows.h causes errors like `"No Target Architecture"`. On the other hand, windows.h includes winnt.h so there's no point to include it again.
What I mean is that winnt.h (when included via windows.h) defines Interlocked polyfills (without a leading underscore) in terms on compiler intrinsics (Interlocked functions with an underscore). If an intrinsic is not available, winnt.h polyfills use a CAS loop (see InlineInterlocked* functions). At least on x86/x64, winnt.h uses MSVC intrinsics without including intrin.h. It simply declares the prototype and uses pragma intrinsic. Best Regards! Luca ________________________________ Da: LIU Hao <[email protected]> Inviato: venerdì, giugno 12, 2026 4:39:32 AM A: Luca Bacci <[email protected]>; [email protected] <[email protected]> Oggetto: Re: R: R: [Mingw-w64-public] Question: library version of interlocked functions 在 2026-6-12 04:02, Luca Bacci 写道: > > In C, if a function is defined `static inline` then it will not be callable > > from a user-defined inline > function with external linkage > > Very intersting! Didn't know that. Windows SDK also defines Interlocked > functions in winnt.h as inline > with external linkage. I guess we should continue doing the same, then :) MSVC seems to implement `__inline` as C++ inline, with vague linkage. (not sure about `inline`) > > Is there a reason why someone wants to do that? Why would someone want to > > declare a function whose > name is known to be reserved and compiler-specific? > > Don't know, but winnt.h from Windows SDK does that: > > #include <Windows.h> > > #ifdef __INTRIN_H_ > #error "intrin.h included" > #endif > > Well, actually it depends on that target architecture. It compiles fine on > x86 and x64, but fails on > ARM64. Perhaps users want to use some intrinsics but don't want to bring all > of intrin.h in the global > namespace (quite questionable if you ask me!) I don't get your point. Microsoft winnt.h has a dependency on non-builtin target-identification macros such as `_AMD64_` which are defined by windows.h, so including winnt.h without windows.h causes errors like `"No Target Architecture"`. On the other hand, windows.h includes winnt.h so there's no point to include it again. -- Best regards, LIU Hao _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
