[#22846] GCC 4.4.1 support in Windows

In this commit i've fixed crash when opening file browser. This crash was caused
by different _stat structures size in storage.c and filelist.c (because of force
setting __MSVCRT_VERSION__ in storage.c), other errors from report
were fixed earlier.

I've used _stati64 strcutrure and functions and tested on official
mingw-gcc 3.4.5, official mingw-gcc 4.4.0, tdm-mingw-gcc 4.4.1,
cross mingw-gcc 4.4.4 and cross mingw-gcc 4.2.1-sjlj -- everything was
ok in  this configurations (except openexr and opencollada libraries which
requires sjlj compiler, so i was unable to build blender with that
libraries by official mingw-gcc 4.4.0)
This commit is contained in:
Sergey Sharybin 2010-07-26 10:41:26 +00:00
parent 8eb31b6bcb
commit bf1bee5d03
2 changed files with 7 additions and 8 deletions

@ -58,6 +58,8 @@ struct direntry{
char *path; char *path;
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) #if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
struct _stat64 s; struct _stat64 s;
#elif defined(__MINGW32__)
struct _stati64 s;
#else #else
struct stat s; struct stat s;
#endif #endif

@ -29,11 +29,6 @@
* Some really low-level file thingies. * Some really low-level file thingies.
*/ */
/* needed for mingw & _stat64i32 */
#ifdef FREE_WINDOWS
# define __MSVCRT_VERSION__ 0x0800
#endif
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -255,6 +250,8 @@ void BLI_builddir(char *dirname, char *relname)
// Excluding other than current MSVC compiler until able to test. // Excluding other than current MSVC compiler until able to test.
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) #if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
_stat64(dlink->name,&files[actnum].s); _stat64(dlink->name,&files[actnum].s);
#elif defined(__MINGW32__)
_stati64(dlink->name,&files[actnum].s);
#else #else
stat(dlink->name,&files[actnum].s); stat(dlink->name,&files[actnum].s);
#endif #endif
@ -449,14 +446,14 @@ int BLI_exist(char *name)
if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
res = _stat(tmp, &st); res = _stat(tmp, &st);
if (res == -1) return(0); if (res == -1) return(0);
#elif defined(WIN32) && defined(__MINGW32__) #elif defined(__MINGW32__)
struct stat st; struct _stati64 st;
char tmp[FILE_MAXDIR+FILE_MAXFILE]; char tmp[FILE_MAXDIR+FILE_MAXFILE];
int len, res; int len, res;
BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE);
len = strlen(tmp); len = strlen(tmp);
if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
res = stat(tmp, &st); res = _stati64(tmp, &st);
if (res) return(0); if (res) return(0);
#else #else
struct stat st; struct stat st;