请问一个pwrite函数的问题?
我在32位的linux下写了一个程序,程序代码如下:
#define _FILE_OFFSET_BITS 64
#define __USE_FILE_OFFSET64
#define __USE_LARGEFIILE64
#define _LARGEFILE64_SOURCE
#include <unistd.h>
#include <stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>
int main()
{
int fd;
int count = 128;
off_t offset = 0X80000000;
int ret;
char buf[1024]="hi ! this is pwrite.";
char pathname[128] = "/tmp/1.txt";
fd = open( pathname, O_WRONLY);
printf("size of off_t is %d\n",sizeof(off_t));
if((ret = pwrite(fd, buf, count, offset))==-1)
{
printf("errno = %d\n",errno);
printf("pwrite error\n");
exit(1);
}
else
{
printf("pwrite success\n");
printf("the writed data is:%s", buf);
}
return 0;
}
但是pwrite函数返回-1,errorno是22,但是我把 0X80000000设为0X7fffffff,就很正常。请问这是什么原因?如何解决这个问题?谢谢!