t0m
t0m

Reputation: 3104

C header file not found when Android NDK

I would like to use this language C code in Android by NDK. Data types __off_t and __off64_t are defined in bits/types.h, but I am getting: fatal error: 'bits/types.h' file not found while building app.

I can make a binary a run C program on Ubuntu without any problems but in Android there is problem with include.

#include <jni.h>
#include <stdio.h>
#include <android/log.h>
#include <bits/types.h> <------- not found

Upvotes: 0

Views: 570

Answers (1)

Botje
Botje

Reputation: 31080

Identifiers starting with underscores and the contents of the bits directory are not guaranteed to be portable.

Android has a definition for off64_t and off_t (no underscores) in the <sys/types.h> header.

So you should be able to do:

#include <sys/types.h>
typedef off64_t __off64_t;
typedef off_t __off_t;

... or just rename the types in the code you are trying to port.

... or you can use the the ftruncate64 call that android ships in <unistd.h>?

Upvotes: 1

Related Questions