I tried to write a programm using wchar_t. When I write in ANSI-C and
compile with qcc on a Neutrino x86 target, the following source produces an
‘invalid initializer’ error:
wchar_t text = L"Hello\n";
printf(“Length: %d\n”, wcslen(text));
I looked in some headers for typedef of wchar_t and found out, that it is
typedefed to _Uint32t in ‘target_nto.h’. And _Uint32t is defined in
‘compiler_gnu.h’ to be an unsigned int when the gnu compiler version is
greater 2.7. As the Compiler takes L"Hello\n" as an unsigned long array it
can’t assign the value to a variable of type unsigned int. When I change the
definition in ‘target_nto.h’ from ‘_Uint32t’ to ‘unsigned long’ the source
mentioned above compiles with no errors.
My question: Is it a wrong definition in ‘target_nto.h’ or am I using
wchar_t the wrong way?
If you compile the source above with QCC as an C++ Sourcecode, no errors
occur, because wchar_t is defined as a type by the compiler.