diff options
author | Junio C Hamano <junkio@cox.net> | 2006-01-07 01:33:54 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-01-07 10:51:06 -0800 |
commit | 8f1d2e6f49ee51ac062ab38337a6a70dd1998def (patch) | |
tree | 0054fb58243a1ede631e0d12a0482d37c3476a25 /git-compat-util.h | |
parent | 3be7098ce444395959c856de1eb9312550193aac (diff) | |
download | git-8f1d2e6f49ee51ac062ab38337a6a70dd1998def.tar.gz |
[PATCH] Compilation: zero-length array declaration.
ISO C99 (and GCC 3.x or later) lets you write a flexible array
at the end of a structure, like this:
struct frotz {
int xyzzy;
char nitfol[]; /* more */
};
GCC 2.95 and 2.96 let you to do this with "char nitfol[0]";
unfortunately this is not allowed by ISO C90.
This declares such construct like this:
struct frotz {
int xyzzy;
char nitfol[FLEX_ARRAY]; /* more */
};
and git-compat-util.h defines FLEX_ARRAY to 0 for gcc 2.95 and
empty for others.
If you are using a C90 C compiler, you should be able
to override this with CFLAGS=-DFLEX_ARRAY=1 from the
command line of "make".
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index c353b276f0..12ce6590bb 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1,6 +1,14 @@ #ifndef GIT_COMPAT_UTIL_H #define GIT_COMPAT_UTIL_H +#ifndef FLEX_ARRAY +#if defined(__GNUC__) && (__GNUC__ < 3) +#define FLEX_ARRAY 0 +#else +#define FLEX_ARRAY /* empty */ +#endif +#endif + #include <unistd.h> #include <stdio.h> #include <sys/stat.h> |