Pelles C forum
Pelles C => Bug reports => Topic started by: Mikehg on November 06, 2004, 11:38:23 PM
-
Hi Pelle,
Yeah, me again :)
Using fseek to offset from the current position seems to be giving some strange results?
int cnt;
WORD ChunkID;
FILE* FP1;
FP1=fopen(FileName,"rb");
GET(FP1,&ChunkID,sizeof(WORD));
cnt =ftell(FP1); // cnt = 2 Here
fseek(FP1,10,SEEK_CUR );
cnt =ftell(FP1); // cnt = 0x20A Here
fclose(FP1);
It seems like something weird is going on with the highorder bits of the offset number?
Thanks,
Mike H.
-
btw, GET is a BCX macro:
#define GET(A,B,C)fread(B,1,C,A)
Also, ths person that wrote the original program stated that the problem started after 2.9 beta 5 if that is any help?
Mike H.
-
btw, GET is a BCX macro:
#define GET(A,B,C)fread(B,1,C,A)
Also, ths person that wrote the original program stated that the problem started after 2.9 beta 5 if that is any help?
Mike H.
I just ran your code here with no problem.
#define GET(A,B,C)fread(B,1,C,A)
int main(void)
{
char FileName[] = "main.c";
int cnt;
WORD ChunkID;
FILE * FP1;
FP1 = fopen(FileName,"rb");
GET(FP1,&ChunkID,sizeof(WORD));
cnt = ftell(FP1); // cnt = 2 Here
printf("%d\n", cnt);
fseek(FP1,10,SEEK_CUR );
cnt = ftell(FP1); // cnt = 12 Here
printf("%d\n", cnt);
fclose(FP1);
return 0;
}
John
-
Hi John,
Are you using the latest version ?
Are you linking with the MS runtime?, it will work correctly.
Using the PellesC runtime I still 2 and 522
Thanks,
Mike H.
-
Hi John,
Are you using the latest version ?
Are you linking with the MS runtime?, it will work correctly.
Using the PellesC runtime I still 2 and 522
Thanks,
Mike H.
Sorry, yes I was linking with the MS runtime, and with crt.lib your code does produce the problem.
John
-
It's the previous addition of supporting fflush() on input streams that is causing the problem. fflush() is also used internally by several C runtime functions, causing problems with fseek() in this case. I have no solution at the moment...
Pelle