[sylpheed:35058] struct stat vs GStatBuf
gvanem at broadpark.no
Mon Jan 9 00:45:08 JST 2012
I get lots of warnings from MSVC when compiling code that
uses 'struct stat' and 'g_stat()'. E.g.:
addrbook.c(1690) : warning C4133: 'function' : incompatible types -
from 'stat *' to 'GStatBuf *'
If I add '-D_TIME32_T_DEFINED' to my CFLAGS, all is well. Since
'st_*time' in 'struc stat' then becomes the old 32-bit 'time_t'.
The comment in <gstdio.h> pretty much explains it all in details:
/* Make it clear that we mean the struct with 32-bit st_size and
* 32-bit st_*time fields as that is how the 32-bit GLib DLL normally
* has been compiled. If you get a compiler warning when calling
* g_stat(), do take it seriously and make sure that the type of
* struct stat the code in GLib fills in matches the struct the type
* of struct stat you pass to g_stat(). To avoid hassle, to get file
* attributes just use the GIO API instead which doesn't use struct
* Sure, it would be nicer to use a struct with 64-bit st_size and
* 64-bit st_*time fields, but changing that now would break ABI. And
* in MinGW, a plain "struct stat" is the one with 32-bit st_size and
* st_*time fields.
Bottom line: If we want Sylpheed to work beyond the year 2036, we
should replace the use of 'struct stat' with 'GStructBuf'. Should I make
More information about the Sylpheed