Tcdrain function call with ndk toolchain for android

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

I am having problems because when I build the newest android ndk the tcdrain is not defined in termios.h, however if I go into the android source 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 create ndk it seems to have another termios.h file in sysroot / usr / include / termios.h?

Why won't the newest ndk have the same include files as the newest bionic / libc files?

+3


source to share


2 answers


The source code you are linking indicates that these functions are only defined if the following is executed

#if __ANDROID_API__ >= 21

      

since nayuta said that you will tcdrain

only have with build environment configured with --platform=android21

.



If you cannot use plafform android21, you can still define the actual functions you need.

In the case of tcdrain, a possible replacement would be

#define tcdrain(fd) ioctl(fd, TCSBRK, 1)

      

+3


source


Have you set up your build environment with --platform=android21

or later?

Prior to android 5.0, api level 20 and later, function declarations are replaced with android/legacy_termios_inlines. h

.



If you are configured for Android 5.0 or newer, you can use tcdrain

.

+1


source







All Articles