Skip to content

Commit 63f761d

Browse files
authored
Merge pull request swiftlang#21960 from compnerd/ssize_t
Shims: make the `__swift_ssize_t` handling more portable
2 parents a6bc2b6 + 7bb6185 commit 63f761d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/public/SwiftShims/SwiftStddef.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ typedef __SIZE_TYPE__ __swift_size_t;
2929
#endif
3030

3131
// This selects the signed equivalent of the unsigned type chosen for size_t.
32+
#if __STDC_VERSION__-0 >= 201112l
3233
typedef __typeof__(_Generic((__swift_size_t)0, \
3334
unsigned long long int : (long long int)0, \
3435
unsigned long int : (long int)0, \
3536
unsigned int : (int)0, \
3637
unsigned short : (short)0, \
3738
unsigned char : (signed char)0)) __swift_ssize_t;
39+
#elif defined(__cplusplus)
40+
#include <type_traits>
41+
using __swift_ssize_t = std::make_signed<__swift_size_t>::type;
42+
#else
43+
#error "do not have __swift_ssize_t defined"
44+
#endif
3845

3946
#endif // SWIFT_STDLIB_SHIMS_SWIFT_STDDEF_H

0 commit comments

Comments
 (0)