ftello() and fseeko() android build errors

2.2k Views Asked by At

I am trying to build Android L for 64-bit architecture.

My code goes like:

#if (HAS_LARGE_FILE_SUPPORT)
#define _FILE_OFFSET_BITS 64   //Defined in header file


/*Some File operations*/
#if HAS_LARGE_FILE_SUPPORT
     return fseeko(iFile, offset, seekmode);
#else
     return fseek(iFile, offset, seekmode);


/*Some File operations*/
    #if HAS_LARGE_FILE_SUPPORT
         return ftello(iFile, offset, seekmode);
    #else
         return ftell(iFile, offset, seekmode);

I am getting below ftello and fseeko errors:

error: call to 'ftello' declared with attribute error: not available with _FILE_OFFSET_BITS=64

error: call to 'fseeko' declared with attribute error: not available with _FILE_OFFSET_BITS=64

I checked about fseeko and ftello, on the manual pages it is mentioned that defining _FILE_OFFSET_BITS with the value 64 will turn off_t into a 64-bit type. Still I am seeing this error. I checked about this error but couldn't find any satisfactory answer.

It will be really helpful if anyone can help me with this.

2

There are 2 best solutions below

0
user3629249 On

the first #if is being applied to the whole posted code and not just to the next line.

similar conditions exist for the other #if and #else compile conditionals,

I.E. each #if ... must be ended with a #endif

0
alijandro On

I solved similar issue by specifying api to 24 when create standalone ndk

./make_standalone_toolchain.py --arch arm --api 24 --stl libc++ --install-dir /tmp/ndk

From ndk file sysroot/usr/include/stdio.h, it looks like ftello only support for api greater or equal than 24

#if __ANDROID_API__ >= 24
int fgetpos(FILE* __fp, fpos_t* __pos) __RENAME(fgetpos64) __INTRODUCED_IN(24);
int fsetpos(FILE* __fp, const fpos_t* __pos) __RENAME(fsetpos64) __INTRODUCED_IN(24);
int fseeko(FILE* __fp, off_t __offset, int __whence) __RENAME(fseeko64) __INTRODUCED_IN(24);
off_t ftello(FILE* __fp) __RENAME(ftello64) __INTRODUCED_IN(24);
#endif /* __ANDROID_API__ >= 24 */