Hi there, I maintain a GCC port for a small 16 bit processor called XAP2+. I'm having problems with strings of wide characters.
I have the following defines, among others: #define BITS_PER_UNIT 16 ... #define WCHAR_TYPE "int" #define WCHAR_TYPE_SIZE 16 So, I'm expecting char and wchar_t to both be 16 bits wide. This mostly works fine. However, when outputing assembler for wide strings, it all goes wrong. Internally, gcc stores the string as a char*, so a string literal like this: L"foo" Is translated by libcpp into something like this: "\0f\0o\0o" The string gets passed around in a STRING_CST and varasm uses ASM_OUTPUT_ASCII to write some assembler. However, at this point, I need to do different things depending on whether I'm dealing with wide or narrow characters (ie, wide characters have two octets packed into 16 bits, and narrow characters are {sign,zero} extended to 16 bits) and that information seems to have been thrown away. I have a bodge, which involves looking at the type of the STRING_CST in varasm, guessing if it's wide and maybe calling a new assemble_string_wide function. I'd be interested to hear any comments or suggestions. I'm working with gcc 4.0.2. Ned.