Search code examples
androidlinuxandroid-ndklibctoolchain

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?


Solution

  • 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)