ftello() and fseeko() android build errors
Asked Answered
W

2

6

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.

Weitzel answered 28/9, 2015 at 15:3 Comment(12)
Do you define -D_LARGEFILE_SOURCE (See https://mcmap.net/q/606190/-what-is-the-difference-between-_largefile_source-and-_file_offset_bits-64/694576)?Adown
@Adown Thanks for replying, I tried defining the above flag also, but still I am getting same error. #define _LARGEFILE_SOURCE 1 #define _LARGEFILE64_SOURCE 1Weitzel
Perhaps the problem is in the prototypes for the functions. that return type of 'return' probably is not correct.Spiritualize
this is the correct syntax for ftello() : int fseeko(FILE *stream, off_t offset, int whence); which does not match the prototypes you postedSpiritualize
@user3629249: "... correct syntax for ftello() : int fseeko(..." Err, what please?Adown
Works perfectly for me. Do you define the macros in your source? I believe that's to localized. You have to define them in your Application.mk. APP_CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64Khanna
It should also be noted, that ftell only accepts one argument, the FILE*. And fseek is only changed, that offset accepts an off_t and ftell returns an off_t, instead of just long.Khanna
@Adown He is correct, though. The signatures are as follows: int fseeko(FILE *stream, off_t offset, int whence) and off_t ftello(FILE *stream). Taken from the linux man pages here.Khanna
I cannot reproduce your error, could you show us your Application.mk and Android.mk, please?Khanna
@user3629249: I was referring to your comment relating: ftello and fseeko, even quoting it.Adown
@Leandros: My comment was not about right or wrong, but of what user3629249 actually way trying to express. Just re-read the comment: #32826675Adown
@Adown Oh. haha. Missed that.Khanna
M
2

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 */
Mainly answered 8/7, 2019 at 11:42 Comment(0)
S
0

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

Spiritualize answered 7/10, 2015 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.