LRN wrote:

We've got a complaint about crashes when using g_stat() in glib. Debugging
showed that sizeof stat.st_size == 4 in user application, but sizeof stat
st_size == 8 in glib.

Turns out, MinGW-w64 defines 'off_t' (the type of st_size) as a synonym for
'long', and 'long' is always[1] 32-bit on Windows.

I imagined one had to compile using '-D_FILE_OFFSET_BITS=64' for this.
Try the attached test program.

I'm getting (your case):
   _FILE_OFFSET_BITS: not defined
   sizeof stat::st_size: 4

and:
   _FILE_OFFSET_BITS = 64
   sizeof stat::st_size: 8

Also, ref: https://wiki.qt.io/MinGW-64-bit

--
--gv

/*
 * Compare to output of:
 *   gcc -m64 -o gcc-file_offset_bits-test.exe gcc-file_offset_bits-test.c
 *
 *  versus:
 *   gcc -m64 -D_FILE_OFFSET_BITS=64 -o gcc-file_offset_bits-test.exe 
gcc-file_offset_bits-test.c
 */

#include <stdio.h>

static void message (void)
{
#ifdef _FILE_OFFSET_BITS
  printf ("_FILE_OFFSET_BITS = %d\n", _FILE_OFFSET_BITS);
#else
  printf ("_FILE_OFFSET_BITS: not defined\n");
#endif
}

#include <sys/stat.h>

int main (void)
{
  struct stat st;
  message();
  printf ("sizeof stat::st_size: %u\n", sizeof(st.st_size));
  return (0);
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to