GNU Toolchains

Resources

Mailing Lists

Why do I get errors about wchar_t when linking code built with RealView?

Question

When I try to link code built with RealView® with code built with Sourcery G++, I get an error about wchar_t. What should I do?

Answer

RealView defines wchar_t as a 16-bit type. Sourcery G++ defines wchar_t as a 32-bit type. Both choices are allowed by the ABI for the ARM Architecture, so neither choice is wrong. The linker notices the mismatch and issues an error message to keep you from accidentally linking incompatible code.

If you want RealView to use a 32-bit type for wchar_t, to match GCC, use the --wchar32 option to RealView.

If you want GCC to use a 16-bit wchar_t, for compatibility with RealView, use -fshort-wchar. Bear in mind that libraries provided with Sourcery G++ or by third parties may be incompatible with -fshort-wchar.


This entry was last updated on 5 October 2009.