Re: `btowc' deprecated in Android NDK r30

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <3957168.kQq0lBPeGt@cagnes>
Hi Po Lu,

> Building Emacs with the latest prerelease of r30 of the Android NDK,
> with an __ANDROID_API__ of 36, yields the following warning in Gnulib:
> ...
> /home/[...]/android-ndk-r30-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/wchar.h:182:39: note: 'btowc' has been explicitly marked deprecated here
>   182 | wint_t btowc(int __ch) __attribute__((__deprecated__("ASCII-only; use mbtowc() instead")));
>       |                                       ^

This warning is pointless, because btowc is an ISO C function and
therefore will not go away (anytime soon).

I can see the change in the bionic git (
$ git clone https://android.googlesource.com/platform/bionic
$ git checkout android17-release
) in commit b4e215d67df79a79834690d69970807fdfe35173, which has
the title "Document the uselessness of btowc()/wctob()."
So, the intent is just to enhance the documentation of this function,
not to prepare for its removal.

The "deprecation" message "use mbtowc() instead" is nonsense, because
btowc() is thread-safe, while mbtowc() is not.

The same warning could also apply to all <ctype.h> functions. But the
Bionic developer has not changed <ctype.h> accordingly.

> I think some measures should be taken to suppress or address this
> warning.

Not in Gnulib. Just ignore it, like the sprintf() or strcat() warnings
on OpenBSD.

But feel free to report it to Elliott Hughes <[email protected]>, so that
he can provide an opt-out for the warning and fix the message. That's
the point of having prereleases, right?

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.