Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tcdrain function call with ndk toolchain for android

I'm trying to use tcdrain function call defined in termios.h by compiling my c code with the android ndk.

I'm having issues because when I build the newest android ndk, tcdrain is not defined in termios.h, however if I go inside the android source code it is defined in termios.h for bionic.

For example: https://github.com/android/platform_bionic/blob/master/libc/include/termios.h#L44

But when I build the ndk, it seems to have a different termios.h file in sysroot/usr/include/termios.h?

Why would the newest ndk not have the same include files as the newest bionic/libc files?

like image 588
kyle Avatar asked May 19 '26 19:05

kyle


1 Answers

The source code you linked states that those functions are defined only if the following holds

#if __ANDROID_API__ >= 21

so, as nayuta said you will have tcdrain only with build environment configured with --platform=android21.

If you can not use plafform android21, you may still define yourself the functions you need.

In case of tcdrain a possible replacement would be

#define tcdrain(fd) ioctl(fd, TCSBRK, 1)
like image 135
Carlo Lobrano Avatar answered May 22 '26 09:05

Carlo Lobrano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!