Web lists-archives.com

Re: [Mingw-users] I need a compatible stat64

On Tue, Jan 5, 2016 at 7:56 AM, Eli Zaretskii <eliz@xxxxxxx> wrote:
> Date: Mon, 4 Jan 2016 22:02:20 -0800
> From: Greg Jung <gvjung@xxxxxxxxx>
> I'm building a program that uses a subroutine with a lot of file access,
> several months back - compiling using mingw-w64 - I switched the use
> of stat() to that of stat64() in order to get a 64-bit file size. This works
> fine
> in mingw-w64, cygwin, and linux but I find now it is invalid in this
> mingw. Can someone suggest a viable workaround?

What version of the MinGW runtime do you have?
mingw 3.21, recently built from sourceforge download. 

$ gcc -v
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)

In any case, I think you want _stat64, not stat64.  Just look at
what's in your sys/stat.h header file, and take it from there.
I want to use a name that is not platform-specific.  
stat64 is available and documented ...


maybe the best way would be to #define _FILE_OFFSET_BITS 64 
and use stat - although it doesn't appear stat.h would catch that.  Also, it leaves the
type ambiguous for the programmer.

BTW, I found a segmentation fault error when compiling this example (presented with stat64 removed):

(which worked compiled with the mingw-w64 gcc 5.2)

MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe