GNOME Bugzilla – Bug 675171
Fix stat-related issues with MinGW
Last modified: 2012-04-30 20:39:57 UTC
This code (example from gstfilesrc.c): #ifdef G_OS_WIN32 #include <io.h> /* lseek, open, close, read */ /* On win32, stat* default to 32 bit; we need the 64-bit * variants, so explicitly define it that way. */ #define stat __stat64 #define fstat _fstat64 #undef lseek #define lseek _lseeki64 #undef off_t #define off_t guint64 /* Prevent stat.h from defining the stat* functions as * _stat*, since we're explicitly overriding that */ #undef _INC_STAT_INL #endif #include <sys/stat.h> Means that <sys/stat.h>, when included, gets mangled (all occurrences of "stat" are replaced by "__stat64"), which results in redefinition of the "__stat64" structure. Until http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=19d4c0ba73a84bfb179dcf2c09be1e4cb763c158 this was averted by gstplugin.h including <sys/stat.h> early on.
Created attachment 213117 [details] [review] Fix stat-related issues with MinGW This is a short version. Only adds two lines to a public header, but fixes everything. Fixing this without altering public header requires re-arranging #includes in several source files. I'll try that and submit an alternative patch.
Created attachment 213123 [details] [review] Rearrange sys/stat.h inclusion point This is the other approach. Apparently, it came out to be easier than i expected, so this patch is also small.
Pushed, thanks: commit 8a962bc1ab6dc749f9bf8fe21e9b1bbbac84ab8b Author: Руслан Ижбулатов <lrn1986@gmail.com> Date: Mon Apr 30 20:29:21 2012 +0400 filesrc: rearrange sys/stat.h inclusion point for MinGW gstplugin.h used to include this for us, but doesn't any longer. https://bugzilla.gnome.org/show_bug.cgi?id=675171 I don't think a public header should be including system includes unless that is required for the structs or API exposed in that header, so much prefer the second patch.