git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] MSVC: fix stat definition hell

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Sep 11, 2013, 16:02 UTC
Message-ID
<52309401.7000508@gmail.com>
In-Reply-To
<522FA9E1.7010705@gmail.com>
On 11.09.2013 01:23, Karsten Blees wrote:
Show 5 quoted lines
> In msvc.h, there's a couple of stat related functions defined diffently
> from mingw.h. When we remove these definitions, the only problem we get is
> "warning C4005: '_stati64' : macro redefinition" for this line in mingw.h:
> 
> #define _stati64(x,y) mingw_stat(x,y)
I have a similar patch at [1] to fix similar compilation issues with MinGW runtime version 4.0, which was recently released. I like your patch better, so I've rebased mine on top of yours:
[PATCH] MinGW: Fix stat definitions to work with MinGW runtime version 4.0
For an overview of changes in mingwrt-4.0 see:
    http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0.0/tree/NEWS
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 compat/mingw.c   | 1 -
 compat/mingw.h   | 9 +++++++++
 config.mak.uname | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 96d9ac4..29c051f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -616,7 +616,6 @@ int mingw_stat(const char *file_name, struct stat *buf)
 	return do_stat_internal(1, file_name, buf);
 }
 
-#undef fstat
 int mingw_fstat(int fd, struct stat *buf)
 {
 	HANDLE fh = (HANDLE)_get_osfhandle(fd);
diff --git a/compat/mingw.h b/compat/mingw.h
index b521900..0d2faac 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -278,11 +278,20 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
 #define lseek _lseeki64
 
 /* use struct stat with 64 bit st_size */
+#ifdef stat
+#undef stat
+#endif
 #define stat _stati64
 int mingw_lstat(const char *file_name, struct stat *buf);
 int mingw_stat(const char *file_name, struct stat *buf);
 int mingw_fstat(int fd, struct stat *buf);
+#ifdef fstat
+#undef fstat
+#endif
 #define fstat mingw_fstat
+#ifdef lstat
+#undef lstat
+#endif
 #define lstat mingw_lstat
 
 #ifndef _stati64
diff --git a/config.mak.uname b/config.mak.uname
index 9249ee3..983ecc1 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -499,7 +499,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
 	NO_D_INO_IN_DIRENT = YesPlease
-	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
-- 
1.8.3.mingw.1.2.g56240b5.dirty

I don't think we should squash this patch to yours, however, because yours addressed MSVC compilation issues, and mine address MinGW compilation issues. But my patch could go to your branch.

[1] https://github.com/sschuberth/git/commit/841cdf60faa134eef031a7cf6d6692473a18cb65

-- 
Sebastian Schuberth
Previous: Eric SunshineNext: Junio C Hamano
Message 6 of 9 in “Fix MSVC compile errors and cleanup stat definitions”
  1. 0/3 Fix MSVC compile errors and cleanup stat definitionsKarsten Blees, Sep 10, 2013
  2. 1/3 MSVC: fix compile errors due to missing libintl.hKarsten Blees, Sep 10, 2013
  3. 2/3 MSVC: fix compile errors due to macro redefinitionsKarsten Blees, Sep 10, 2013
  4. 3/3 MSVC: fix stat definition hellKarsten Blees, Sep 10, 2013
  5. Eric SunshineSep 11, 2013
  6. Sebastian SchuberthSep 11, 2013
  7. Junio C HamanoSep 11, 2013
  8. Sebastian SchuberthSep 11, 2013
  9. Junio C HamanoSep 11, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.