Skip to content

Commit ddcaa64

Browse files
authored
Update Versions.cpp
Check the major clang version before attempting to use `__has_embed` or `__clang_major__`.
1 parent 5f0572b commit ddcaa64

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/_TestingInternals/Versions.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const char *swt_getTestingLibraryVersion(void) {
1818
#if defined(SWT_TESTING_LIBRARY_VERSION)
1919
// The current environment explicitly specifies a version string to return.
2020
return SWT_TESTING_LIBRARY_VERSION;
21-
#elif __has_embed("../../VERSION.txt")
21+
#elif __clang_major__ >= 19
22+
#if __has_embed("../../VERSION.txt")
2223
static constinit auto version = [] () constexpr {
2324
// Read the version from version.txt at the root of the package's repo.
2425
char version[] = {
@@ -43,6 +44,10 @@ const char *swt_getTestingLibraryVersion(void) {
4344
#warning SWT_TESTING_LIBRARY_VERSION not defined and VERSION.txt not found: testing library version is unavailable
4445
return nullptr;
4546
#endif
47+
#else
48+
#warning SWT_TESTING_LIBRARY_VERSION not defined and could not read from VERSION.txt at compile time: testing library version is unavailable
49+
return nullptr;
50+
#endif
4651
}
4752

4853
void swt_getTestingLibraryCommit(const char *_Nullable *_Nonnull outHash, bool *outModified) {

0 commit comments

Comments
 (0)