[GRASS-dev] diglib test.c fails on 64bit win

Markus Metz markus.metz.giswork at googlemail.com
Wed May 19 02:58:08 EDT 2010


Glynn Clements wrote:
>
> Markus Metz wrote:
>
>> So, how about
>
>>  #ifdef __MINGW32__
>
> #if defined(__MINGW32__) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
>
>> +/* add/remove as needed */
>>  #define off_t off64_t
>>  #define fseeko fseeko64
>>  #define ftello ftello64
>> +#define lseek lseek64
>> +#define tell tell64
>> +#define seek seek64
>> +#define stat stat64
>> +#define fstat fstat64
>
> If you redirect stat() to stat64(), you also need to redirect
> "struct stat" to "struct __stat64". But I'm not sure how to go about
> that.

I was looking around a bit in the Linux system headers but could not
find anything. Either redirecting stat() to stat64() seems to work out
of the box or an explicit stat64() expects struct stat64.

Alternatively, I found 26 files in trunk using struct stat. All these
would need to be modified by hand...
>
> Also, there are two 64-bit stat interfaces, stati64() and
> "struct _stati64", and stat64() and "struct __stat64". AFAICT, the
> latter requires MSVCRT >= 6.1 (and uses __time64_t instead of time_t
> for the timestamps).

At first glance it seems that the timestamp is usually not used in
grass, only file size is used. In these cases, stat() could be
replaced in trunk with
curr_pos = G_ftell(fp)
G_fseek(fp, 0, SEEK_END)
filesize = G_ftell(fp)
G_fseek(fp, curr_pos, SEEK_SET)

something like that is done e.g. in lib/vector/Vlib/open.c (all branches)


More information about the grass-dev mailing list