[libc-commits] [libc] [libc] Some more MSVC compatibility in src/__support. (PR #158108)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Thu Sep 11 09:37:04 PDT 2025


================
@@ -16,10 +16,32 @@
 namespace LIBC_NAMESPACE_DECL {
 
 // We rely on compiler preprocessor defines to allow for cross compilation.
+#ifdef LIBC_COMPILER_IS_MSVC
+#define __BYTE_ORDER__ 0
+#define __ORDER_LITTLE_ENDIAN__ 0
+#define __ORDER_BIG_ENDIAN__ 1
+
+LIBC_INLINE static uint16_t __builtin_bswap16(uint16_t v) {
----------------
jhuber6 wrote:

Not a fan of defining something with the exact builtin name (even though libc can technically use compiler reserved names), likely gives people the wrong idea. Could we turn this bswap stuff into a templated helper and specialize it different for MSVC?

https://github.com/llvm/llvm-project/pull/158108


More information about the libc-commits mailing list