Urmatorul cod s-a comilat fara erori sau avertismente:
/*
gcc -g3 -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 exemplu.c -o exemplu
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
off_t offset=3000000000LL;
off_t offset_max=3000000000LL+10LL;
int
main (int argc, char **argv)
{
char c;
long fd;
printf("sizeof(off_t)=%d\n",sizeof(off_t));/* egal 8 */
if((fd=open("fisier_mare.dat",O_RDONLY))==-1)
{
perror("deschidere fisier");
exit(1);
}
for(;offset<offset_max;offset++)
{
if (lseek(fd,offset,SEEK_SET)==-1)
{
perror("eroare lseek");
exit(1);
}
if (read(fd,&c,1)==-1)
{
perror("eroare read");
exit(1);
}
printf("cod ASCII citit=%d \n",c);
}
return 0;
}
In conluzie pentru prelucrari de intregi pe 64 de biti
ar trebui sa folosec tipul int64_t in loc de long long pentru portabilitate
sau ar fi mai bine sa folosesc un layer neutru , unde sa folosesc un tip de
ex. bigint care pt diferite platforme sa insemne
long long pt linux, solaris
long pt cele implicit pe 64 de biti
......
Sau mai direct int64_t bigint?
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
---
Detalii despre listele noastre de mail: http://www.lug.ro/