git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-compat-util(msvc): C11 does not imply support for zero-sized arrays
@ 2021-12-06 20:48 Johannes Schindelin via GitGitGadget
  2021-12-06 21:48 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-12-06 20:48 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

This seems to be required to define `FLEX_ARRAY` in a manner that MSVC
in C11 mode accepts. Without this fix, building Git for Windows'
experimental FSCache code would fail thusly:

	error C2229: struct 'heap_fsentry' has an illegal zero-sized array

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    git-compat-util(msvc): C11 does not imply support for zero-sized arrays
    
    In Git for Windows' continuously-rebased branches, I found this problem
    [https://github.com/git-for-windows/git/runs/4431149285?check_suite_focus=true#step:9:14507]
    (which uses FLEX_ARRAY correctly, but fails because FLEX_ARRAY is no
    longer defined as required by MS Visual C).
    
    This patch is based on bc/require-c99.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1094%2Fdscho%2Fflex-array-and-msvc-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1094/dscho/flex-array-and-msvc-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1094

 git-compat-util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 19943e214ba..c9f508b3a83 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -46,7 +46,7 @@
 /*
  * See if our compiler is known to support flexible array members.
  */
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && (!defined(__SUNPRO_C) || (__SUNPRO_C > 0x580))
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(_MSC_VER) && (!defined(__SUNPRO_C) || (__SUNPRO_C > 0x580))
 # define FLEX_ARRAY /* empty */
 #elif defined(__GNUC__)
 # if (__GNUC__ >= 3)

base-commit: 7bc341e21b566c6685b7d993ca80459f9994be38
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-09 21:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-06 20:48 [PATCH] git-compat-util(msvc): C11 does not imply support for zero-sized arrays Johannes Schindelin via GitGitGadget
2021-12-06 21:48 ` Junio C Hamano
2021-12-06 22:25 ` Neeraj Singh
2021-12-07 21:33   ` Johannes Schindelin
2021-12-07 22:22     ` Neeraj Singh
2021-12-07 22:59       ` rsbecker
2021-12-09 11:00     ` Phillip Wood
2021-12-09 21:18       ` Junio C Hamano
2021-12-09  1:39 ` Junio C Hamano
2021-12-09  1:49   ` Neeraj Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).