[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>
This commit is contained in:
9
cache.h
9
cache.h
@ -81,7 +81,7 @@ struct cache_entry {
|
||||
unsigned int ce_size;
|
||||
unsigned char sha1[20];
|
||||
unsigned short ce_flags;
|
||||
char name[0];
|
||||
char name[FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
#define CE_NAMEMASK (0x0fff)
|
||||
@ -257,7 +257,7 @@ extern int checkout_entry(struct cache_entry *ce, struct checkout *state);
|
||||
extern struct alternate_object_database {
|
||||
struct alternate_object_database *next;
|
||||
char *name;
|
||||
char base[0]; /* more */
|
||||
char base[FLEX_ARRAY]; /* more */
|
||||
} *alt_odb_list;
|
||||
extern void prepare_alt_odb(void);
|
||||
|
||||
@ -271,7 +271,8 @@ extern struct packed_git {
|
||||
unsigned int pack_use_cnt;
|
||||
int pack_local;
|
||||
unsigned char sha1[20];
|
||||
char pack_name[0]; /* something like ".git/objects/pack/xxxxx.pack" */
|
||||
/* something like ".git/objects/pack/xxxxx.pack" */
|
||||
char pack_name[FLEX_ARRAY]; /* more */
|
||||
} *packed_git;
|
||||
|
||||
struct pack_entry {
|
||||
@ -286,7 +287,7 @@ struct ref {
|
||||
unsigned char new_sha1[20];
|
||||
unsigned char force;
|
||||
struct ref *peer_ref; /* when renaming */
|
||||
char name[0];
|
||||
char name[FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
extern int git_connect(int fd[2], char *url, const char *prog);
|
||||
|
Reference in New Issue
Block a user