5

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.

alk
  • 69,737
  • 10
  • 105
  • 255
  • Do you define `-D_LARGEFILE_SOURCE` (See http://stackoverflow.com/q/14184031/694576)? – alk Sep 28 '15 at 17:17
  • @alk Thanks for replying, I tried defining the above flag also, but still I am getting same error. `#define _LARGEFILE_SOURCE 1` `#define _LARGEFILE64_SOURCE 1` – Android_Noob Sep 29 '15 at 07:09
  • Perhaps the problem is in the prototypes for the functions. that return type of 'return' probably is not correct. – user3629249 Sep 30 '15 at 08:49
  • this is the correct syntax for ftello() : `int fseeko(FILE *stream, off_t offset, int whence);` which does not match the prototypes you posted – user3629249 Sep 30 '15 at 08:51
  • 1
    @user3629249: "*... correct syntax for ftello() : `int fseeko(...`*" Err, what please? – alk Oct 03 '15 at 11:50
  • 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=64` – Leandros Oct 06 '15 at 07:53
  • 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`. – Leandros Oct 06 '15 at 08:04
  • @alk 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](http://man7.org/linux/man-pages/man3/ftello.3.html). – Leandros Oct 06 '15 at 08:06
  • I cannot reproduce your error, could you show us your `Application.mk` and `Android.mk`, please? – Leandros Oct 06 '15 at 08:11
  • @user3629249: I was referring to your comment relating: `ftello` and `fseeko`, even quoting it. – alk Oct 07 '15 at 14:59
  • @Leandros: My comment was not about right or wrong, but of what *user3629249* actually way trying to express. Just re-read the comment: http://stackoverflow.com/questions/32826175/ftello-and-fseeko-android-build-errors?noredirect=1#comment53556232_32826175 – alk Oct 07 '15 at 15:00
  • @alk Oh. haha. Missed that. – Leandros Oct 07 '15 at 15:33

2 Answers2

1

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 */
alijandro
  • 11,627
  • 2
  • 58
  • 74
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

andrewsi
  • 10,807
  • 132
  • 35
  • 51
user3629249
  • 16,402
  • 1
  • 16
  • 17