[Issue 24132] ImportC: Add support for wchar_t, char16_t, char32_t

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 28 09:48:02 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24132

--- Comment #4 from Adam Wilson <flyboynw at gmail.com> ---
So I was poking around the compiler source today and I noticed that in lexer.d
at line 80 there is a reference to wchar_t in ImportC specific code, so it
appears to know about wide-chars in C. 

Then I discovered Ckeywords in tokens.d. So all we have to do is add wchar_ and
dchar_ to that list and add the following to importc.h

#define wchar_t wchar
#define char16_t wchar
#define char32_t dchar

A little hacky maybe, but for ImportC it would work, and it would allow us to
use D style strings natively which is the semantically correct outcome. IIRC,
the wchar and dchar types are unsigned short and unsigned int respectively when
using export(C) so that should function as normal.

--


More information about the Digitalmars-d-bugs mailing list