zizi21
asked on
64 bits : off_t , off64_t
hi,
the file that i am trying to write is going to be about 12GBs.
I browse the net and found that it is not advisable to use unsigned int but use off64_t or off_t but when i put it , i get error error: ‘off64_t’ was not declared in this scope
is there a specific header file i need to put? thanks...
the file that i am trying to write is going to be about 12GBs.
I browse the net and found that it is not advisable to use unsigned int but use off64_t or off_t but when i put it , i get error error: ‘off64_t’ was not declared in this scope
is there a specific header file i need to put? thanks...
What OS are you using ? Is it a 64bit or 32bit OS ?
ASKER
i need it to work on 32 bit and 64 bit machine..
for testing purpose, i am using mac, but i need to run on both (32 bit and 64 bit) . thanks.
for testing purpose, i am using mac, but i need to run on both (32 bit and 64 bit) . thanks.
Hi zizi21.
IIRC your questions are generally Linux related. If this is the case here and you are using gcc you can enable large file support in the standard C library by defining _FILE_OFFSET_BITS=64 during the build phase of your project.
The following link contains more info.
http://www.suse.de/~aj/linux_lfs.html
IIRC your questions are generally Linux related. If this is the case here and you are using gcc you can enable large file support in the standard C library by defining _FILE_OFFSET_BITS=64 during the build phase of your project.
The following link contains more info.
http://www.suse.de/~aj/linux_lfs.html
>> for testing purpose, i am using mac
I suspect the LFS info will be applicable to a max too if you are using OS-X
I suspect the LFS info will be applicable to a max too if you are using OS-X
ASKER
evilrix,
thanks for the reply.
my problem is that i am saving the pointer of the file in the code as well and that is of type unsigned int. since unsigned int canbe as big as 12 GB, i need to use something bigger...
thanks for the reply.
my problem is that i am saving the pointer of the file in the code as well and that is of type unsigned int. since unsigned int canbe as big as 12 GB, i need to use something bigger...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
" It's therefore important to always use the correct types and to not use e.g. int instead of off_t"
could i clarify this...i am using unsigned int when i get value from ftell, store positions in file using unsigned int,,,is that wrong ? the reason i used unsigned int was because it could store more instead of ints...
could i clarify this...i am using unsigned int when i get value from ftell, store positions in file using unsigned int,,,is that wrong ? the reason i used unsigned int was because it could store more instead of ints...
>> ,is that wrong
Yes
>> the reason i used unsigned int was because it could store more instead of ints...
int us a signed value and unsigned int is an unsigned value. The different is that int can store positive and negative values whereas unsigned in can only store positive values. Neither are the correct type to use when dealing with large files as neither are guaranteed to be 64 bit, even on a 64 bit platform.
The type off_t IS guaranteed to be 64 bit when LFS is enabled.
Yes
>> the reason i used unsigned int was because it could store more instead of ints...
int us a signed value and unsigned int is an unsigned value. The different is that int can store positive and negative values whereas unsigned in can only store positive values. Neither are the correct type to use when dealing with large files as neither are guaranteed to be 64 bit, even on a 64 bit platform.
The type off_t IS guaranteed to be 64 bit when LFS is enabled.
ASKER
thanks a million.. i would start changing the types to off_t type now...thanks again..
ASKER
thanks and God bless you.
>> thanks a million
No worries... if you need more info just post back here.
No worries... if you need more info just post back here.
ASKER
thanks