AnsweredAssumed Answered

wchar_t warning when linking with library generated by another toolchain

Question asked by LPCware Support on Mar 31, 2016

There is a standard know 'issue' with interworking code compiled with different toolchains, which is a result of the ARM AEABI documentation allowing the size of wchar_t to be compiler defined. GCC uses a wchar_t size of 4, but some other toolchains use a size of 2.

 

This can result in linker warning similar to the one below being generated when building an application with LPCXpresso which links in a library archive or object file generated using another toolchain:

 

c:/nxp/lpcxpresso_7.2.0_153/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe: warning: C:\workspace\myproj\src\libextcode.a(code.o) uses 2-byte wchar_t yet the output is to use 4-byte wchar_t; use of wchar_t values across objects may fail

 

Unless your codebase actually uses wchar types (generally unlikely for most embedded application), then you can solve this problem by simply adding the linker flag "-no-wchar-size-warning" to your LPXpresso project by navigating to

 

Project - Properties - C/C++ Build - Settings - Tool Settings - MCU Linker - Miscellaneous

 

and adding "-no-wchar-size-warning" to the "Other options" box. Remember to do this for all Build Configurations (Debug and Release).

 


See also:

Outcomes