GNOME Bugzilla – Bug 568632
__MSVCRT_VERSION__ not defined with mingw, causing "storage size of 'stat_results' isn't known" compile error
Last modified: 2009-04-17 15:08:56 UTC
__MSVCRT_VERSION__ is a constant that tells mingw which version of MSVCR is required by the application. When it is not defined, it is defaulted to 0x0600 in _mingw.h system header. However, gstreamer uses a feature that, according to mingw headers, are only available in MSVCR versions newer than 60 (the __stat64 structure). This appeared at devel mailing list, but never made it to the bug tracker - http://www.nabble.com/gstreamer-mingw32-__stat64-td19835510.html My opinion is that __MSVCRT_VERSION__ should be defined as 0x0601 in config.h or in gst.h
*** Bug 568828 has been marked as a duplicate of this bug. ***
Defining __MSVCRT_VERSION__ in config.h works only if config.h is included first. For that gst/gst.c has to be modified to include gst_private.h before gstconfig.h Alternatively you can #undef __MSVCRT_VERSION__ before defining it.
Created attachment 129175 [details] [review] Fixes the lack of proper __MSVCRT_VERSION__ constant Adds __MSVCRT_VERSION__ definition to config.h (regenerate configure script with autogen.sh) Includes gst_private.h before gstconfig.h. gstconfig.h pulls parser.h and, eventually, stat.h, but we need __MSVCRT_VERSION__ defined before stat.h is included. __MSVCRT_VERSION__ is defined in config.h, so it has to be included before stat.h, that is - before gstconfig.h . gst_private.h does just that. Alternatively you can include config.h directly from gst.c, before both gstconfig.h and gst_private.h.
config.h is supposed to be included first, always. Anywhere this is not the case should be fixed. Back in the day, we had a script that checked for this. Since fixing those might take a while, it might be better to define __MSVCRT_VERSION__ using a -D in CFLAGS.
Created attachment 129177 [details] [review] Same as before, but instead of changing the #include order in gst.c it includes config.h directly
*** Bug 576018 has been marked as a duplicate of this bug. ***
Created attachment 132799 [details] [review] same as before but without chunk that's already been fixed The config.h include problem has already been fixed, so updating patch.
Since this causes compile errors, we should try to get it into the release as well IMHO. Jan?
Created attachment 132823 [details] [review] alternative patch Not sure if we should re-define this preprocessor symbol in case the compiler already provides it. Here's an alternative patch that checks if it's set by the compiler and only defines the symbol if the compiler doesn't provide it.
Sounds like a sensible idea. Maybe someone on Windows can confirm if this works for them?
Works for me.
great, thanks for confirming
commit 923b33a31684e736d9a5ed958ca501bdc16e90d6 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Fri Apr 17 15:46:52 2009 +0100 win32: define __MSVCRT_VERSION__ when compiling with MingW, for __stat64 Need to define this when using MingW, so that the includes provide __stat64 and friends. We need at least Windows XP SP2 for this. Fixes #568632.