[GRASS-dev] diglib test.c fails on 64bit win
glynn at gclements.plus.com
Mon May 17 12:44:46 EDT 2010
Markus Metz wrote:
> >> but that is your turf, you can judge what is portable. I guess, in the
> >> near future, MINGW64 will become more popular which is IMHO good and
> >> grass should consider this build environment.
> > I wouldn't assume that Win64 will be any different with regard to LFS.
> > Apart from anything else, "long" is still only 32 bits on Win64.
> I think there is one of int64, int64_t, _int64, _int64_t available if
> a 64-bit integer type is really needed.
Yes; those are also available in Win32.
My point is that Win64 isn't especially different from Win32. Binary
compatibility is much more of an issue on Windows than on Unix, hence
the decision to use a 32-bit "long" on Win64.
> I did some testing on w32 with mingw32, and
> #ifdef __MINGW32__
> #define off_t off64_t
> #define fseeko fseeko64
> #define ftello ftello64
> provided me with a 64-bit off_t. In LibGw32C, there are a number of 64
> variants of standard functions: stat, fstat, seek, fseek, tell, ftell
> are available as 64 variants as e.g. stat64. Somewhere there is also a
All of the necessary 64-bit versions exist in MSVCRT. The issue is
that the headers don't have a "use 64-bit offsets everywhere" macro
like _FILE_OFFSET_BITS. If you want to redefine off_t to off64_t, you
have to manually redirect *everything* which uses off_t to the
appropriate 64-bit versions.
> What about fopen/fopen64 etc?
There isn't an open64() or fopen64(). Unlike Unix, MSVCRT's open() and
fopen() functions don't care about the size of the file.
Unix requires the program to assert that it is "large file aware" by
using open64() or the O_LARGEFILE flag, otherwise it will refuse to
open large files. This prevents the situation where a legacy program
starts working on a large file then suddenly fails when it reaches the
2GiB mark (either due to EOVERFLOW or due to calculated offsets
> In GRASS, config.h does not know about __MINGW32__ even if __MINGW32__
> is (somewhere else) defined, thus off_t is not redefined for mingw32,
> and I placed the redefinitions for testing in another header. Looks
> like a lot of hacking to get LFS for wingrass.
__MINGW32__ is defined by the compiler.
But note that the "#ifdef __MINGW32__" block is within a
"#ifdef USE_LARGEFILES" block, and USE_LARGEFILES isn't defined as a
preprocessor macro (AC_DEFINE), only as a substitution (AC_SUBST), so
all of that LFS stuff at the bottom of config.h is ignored.
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev