Skip to content

Commit 7943ee2

Browse files
committed
fix remain build error on windows
1 parent da96a75 commit 7943ee2

File tree

2 files changed

+24
-37
lines changed

2 files changed

+24
-37
lines changed

include/trlc/platform/core.hpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@
2727
#include <iostream>
2828
#include <sstream>
2929
#include <string>
30+
#include <thread> // For std::this_thread::yield
3031
#include <type_traits>
3132

32-
// Platform-specific intrinsics
33-
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
34-
#include <intrin.h> // For __mm_pause on MSVC
35-
#endif
36-
3733
// Include all platform detection headers in dependency order
3834
#include "trlc/platform/architecture.hpp"
3935
#include "trlc/platform/compiler.hpp"
@@ -396,22 +392,8 @@ inline void initializePlatform() noexcept {
396392
expected, true, std::memory_order_acq_rel)) {
397393
// Another thread is initializing, wait for completion
398394
while (!detail::g_platform_initialized.load(std::memory_order_acquire)) {
399-
// Busy wait with yield hint
400-
#if defined(_WIN32)
401-
#if defined(_MSC_VER)
402-
__mm_pause(); // Intel x86 pause instruction
403-
#else
404-
std::this_thread::yield();
405-
#endif
406-
#elif defined(__GNUC__) || defined(__clang__)
407-
#if defined(__x86_64__) || defined(__i386__)
408-
__builtin_ia32_pause(); // Intel x86 pause instruction
409-
#else
395+
// Use standard thread yield instead of platform-specific intrinsics
410396
std::this_thread::yield();
411-
#endif
412-
#else
413-
std::this_thread::yield();
414-
#endif
415397
}
416398
return;
417399
}

include/trlc/platform/cpp_standard.hpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,28 @@ namespace detail {
102102
* @return CppStandard enum value
103103
*/
104104
constexpr CppStandard detectCppStandard() noexcept {
105-
#ifdef __cplusplus
106-
#if __cplusplus >= 202600L
107-
return CppStandard::cpp_26;
108-
#elif __cplusplus >= 202302L
109-
return CppStandard::cpp_23;
110-
#elif __cplusplus >= 202002L
111-
return CppStandard::cpp_20;
112-
#elif __cplusplus >= 201703L
113-
return CppStandard::cpp_17;
114-
#elif __cplusplus >= 201402L || __cplusplus >= 201103L || __cplusplus >= 199711L
115-
return CppStandard::cpp_pre_17;
116-
#else
117-
return CppStandard::cpp_unknown;
118-
#endif
119-
#else
120-
return CppStandard::cpp_unknown;
121-
#endif
105+
// Use _MSVC_LANG for MSVC, __cplusplus for others
106+
#if defined(_MSVC_LANG)
107+
constexpr long cpp_version = _MSVC_LANG;
108+
#elif defined(__cplusplus)
109+
constexpr long cpp_version = __cplusplus;
110+
#else
111+
constexpr long cpp_version = 0L;
112+
#endif
113+
114+
if (cpp_version >= 202600L) {
115+
return CppStandard::cpp_26;
116+
} else if (cpp_version >= 202302L) {
117+
return CppStandard::cpp_23;
118+
} else if (cpp_version >= 202002L) {
119+
return CppStandard::cpp_20;
120+
} else if (cpp_version >= 201703L) {
121+
return CppStandard::cpp_17;
122+
} else if (cpp_version >= 201402L || cpp_version >= 201103L || cpp_version >= 199711L) {
123+
return CppStandard::cpp_pre_17;
124+
} else {
125+
return CppStandard::cpp_unknown;
126+
}
122127
}
123128

124129
/**

0 commit comments

Comments
 (0)