-1

AFAICT wchar_t is always 32-bit wide on Apple targets.

What is the sign of wchar_t on:

  • x86 Apple Darwin (32-bit MacOSX)
  • x86_64 Apple Darwin (64-bit MacOSX)
  • ARM iOS (32-bit)
  • AArch64 iOS (64-bit)

?

gnzlbg
  • 7,135
  • 5
  • 53
  • 106

1 Answers1

2

ISO/IEC 9899:2017 §7.20.3/4:

If wchar_t (see 7.19) is defined as a signed integer type, the value of WCHAR_MIN shall be no greater than −127 and the value of WCHAR_MAX shall be no less than 127; otherwise, wchar_t is defined as an unsigned integer type, and the value of WCHAR_MIN shall be 0 and the value of WCHAR_MAX shall be no less than 255.

So looking at WCHAR_MIN will tell you.


iOS ABI Function Call Guide:

In iOS, as with other Darwin platforms, both char and wchar_t are signed types.

Swordfish
  • 12,971
  • 3
  • 21
  • 43
  • "So looking at WCHAR_MIN will tell you." I know, the question is: what's the sign of the value that this returns on these systems? – gnzlbg Feb 24 '19 at 17:00
  • @gnzlbg That's up to the compiler, not the architecture. – Govind Parmar Feb 24 '19 at 18:00
  • I thought the ABI of these architectures required a specific type. As in, independently what compiler you use, if you wanted to call a kernel ABI handling this you'd have to stick to whatever ABI the kernel expected. How many compiles target these architectures? I thought it was just clang. How do other compilers differ from clang here? AFAICT there is only one C and C++ standard library available for these. So if you wanted to use those, you'd have to do what they expect. – gnzlbg Feb 24 '19 at 22:36
  • @gnzlbg gcc with glibc also runs on OS X. OS X is FreeBSD after all. – Swordfish Feb 24 '19 at 22:43
  • Sure, but independently of the compiler, the OSX kernel and standard library APIs will expect a particular `wchar_t` type. What's its sign? I'd expect that for this target clang and gcc would need to agree. – gnzlbg Feb 24 '19 at 23:09
  • Thank you. That's slightly different from FreeBSD, where AFAIK `char` and `wchar_t` are unsigned on arm32 and arm64 targets, but signed on 32 and 64-bit x86. – gnzlbg Feb 25 '19 at 20:01