newlib ftello64/fseeko64 not working

A forum for general AmigaOS 4.x support questions that are not platform-specific

newlib ftello64/fseeko64 not working

Postby chris » Sun Oct 23, 2011 12:03 am

Maybe they are not implemented, but if so I'm surprised they are present in the includes. Here is an example I nicked from elsewhere (http://old.nabble.com/Re%3A-ftello64-re ... 03471.html):

Code: Select all
#include <stdio.h> 

int main() 

     FILE * fp; 
     _off64_t pos; 

     fp = fopen("test.dat", "w+b"); 
     fwrite("abcdefghijklmnopqrstuvwxyz", 1, 26, fp); 
     pos = ftello64(fp); 
     printf("ftello64 says our position is %d, it should be 26\n", 
(int)pos); 

     fseeko64(fp, 0, SEEK_END); 
     pos = ftello64(fp); 
     printf("now ftello64 says our position is %d, it should still be 26\n", (int)pos); 

     return 0; 
  } 


This returns:
ftello64 says our position is -1, it should be 26
now ftello64 says our position is -1, it should still be 26

I assume -1 is an error, but I have no documentation as to what this actually means.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: newlib ftello64/fseeko64 not working

Postby xenic » Sun Oct 23, 2011 6:08 pm

@chris
See what happens if you change fopen() to fopen64(). According to my C reference these functions are supposed to return -1 for an error but in newlib EOF is defined as -1 also. That seems like it could lead to some confusion.
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 1160
Joined: Sun Jun 19, 2011 1:06 am

Re: newlib ftello64/fseeko64 not working

Postby chris » Mon Oct 24, 2011 11:58 pm

xenic wrote:@chris
See what happens if you change fopen() to fopen64(). According to my C reference these functions are supposed to return -1 for an error but in newlib EOF is defined as -1 also. That seems like it could lead to some confusion.


Ah, that works, very interesting! - thanks
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm


Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 4 guests

cron