sim: Specify -fshort-wchar as NuttX wchar_t is 16-bit
* For C, wchar_t is provided by the OS. On NuttX, it's uint16_t. (Except wide character literals, which uses the compiler built-in knowledge of wchar_t.) * For C++, wchar_t is a built-in type. It's provided by the compiler. * The compilers built-in wchar depends on the compiler configuration. For the sim, the compilers are usually configured with wchar_t == int, which is 32-bit. * wchar_t should be compatible between C and C++. This commit fixes the mismatches by telling the compiler to use 16-bit wchar_t. An alternative is to make NuttX use 32-bit wchar_t if the compiler is configured with 32-bit wchar_t. It can increase the runtime footprint. While it might be ok for the sim, it might be a problem for real devices.
This commit is contained in:
parent
21c091f903
commit
3fc06ff2d1
|
@ -93,11 +93,16 @@ NM = $(CROSSDEV)nm
|
|||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
# Note: -fshort-wchar for the case where NuttX and the host OS have
|
||||
# differnt wchar_t. On Nuttx, it's uint16_t. On macOS, it's 32-bit.
|
||||
CFLAGS := $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe \
|
||||
-fshort-wchar
|
||||
CXXFLAGS := $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGSXX) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||
$(ARCHCPUFLAGSXX) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe \
|
||||
-fshort-wchar
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) \
|
||||
-fshort-wchar
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
ifeq ($(CONFIG_LIBCXX),y)
|
||||
|
|
Loading…
Reference in New Issue