Question

I compile my Android NDK library with -fshort-wchar. I know the RTL assumes 4-byte wchar_t, I know what I'm doing, the library works. However, on every build linker gives me the following warning for every object file:

ld.exe: warning: MyFile.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

When I provide

LOCAL_LDLIBS := --no-wchar-size-warning

This gives me an "unrecognized option" error.

Was it helpful?

Solution

Adding APP_LDFLAGS += -Wl,--no-wchar-size-warning (to Application.mk) works fine for me on NDKs at least as early as r7.

I assume it would work just the same as:

LOCAL_LDLIBS := -Wl,--no-wchar-size-warning

OTHER TIPS

Have you seen this? The post explains that the --no-wchar-size-warning option will make the linker treat the mismatch as a warning, not an error. As in the enum case, the authors choose to display the message anyway.

You don't see the effect of setting this flag in your project because as detailed elsewhere, using -fshort-wchar automatically adds -Wl,--no-wchar-size-warning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top