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

[PATCH] git-compat-util(msvc): C11 does not imply support for zero-sized arrays

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 6, 2021, 20:48 UTC
Message-ID
<pull.1094.git.1638823724410.gitgitgadget@gmail.com>
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
Next: Junio C Hamano
Message 1 of 10 in “git-compat-util(msvc): C11 does not imply support for zero-sized arrays”
  1. git-compat-util(msvc): C11 does not imply support for zero-sized arraysJohannes Schindelin via GitGitGadget, Dec 6, 2021
  2. Junio C HamanoDec 6, 2021
  3. Neeraj SinghDec 6, 2021
  4. Johannes SchindelinDec 7, 2021
  5. Neeraj SinghDec 7, 2021
  6. rsbecker@nexbridge.comDec 7, 2021
  7. Phillip WoodDec 9, 2021
  8. Junio C HamanoDec 9, 2021
  9. Junio C HamanoDec 9, 2021
  10. Neeraj SinghDec 9, 2021

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.