summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3be7098)
raw | patch | inline | side by side (parent: 3be7098)
author | Junio C Hamano <junkio@cox.net> | |
Sat, 7 Jan 2006 09:33:54 +0000 (01:33 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 7 Jan 2006 18:51:06 +0000 (10:51 -0800) |
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>
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>
blob.c | patch | blob | history | |
cache.h | patch | blob | history | |
commit.c | patch | blob | history | |
git-compat-util.h | patch | blob | history | |
ls-files.c | patch | blob | history | |
object.c | patch | blob | history | |
object.h | patch | blob | history | |
receive-pack.c | patch | blob | history | |
tag.c | patch | blob | history | |
tree.c | patch | blob | history |
index ea52ad5c9d819721ff6f631d7d5b3057fabcd633..84ec1212e7010b8cbf535355d4114eded3007672 100644 (file)
--- a/blob.c
+++ b/blob.c
-#include "blob.h"
#include "cache.h"
+#include "blob.h"
#include <stdlib.h>
const char *blob_type = "blob";
index cb87becb3aaea75915a65e99565c418d6765174b..5fd2687636026c2000b2f39e383af00b45c3627c 100644 (file)
--- a/cache.h
+++ b/cache.h
unsigned int ce_size;
unsigned char sha1[20];
unsigned short ce_flags;
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
#define CE_NAMEMASK (0x0fff)
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);
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 {
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);
diff --git a/commit.c b/commit.c
index edd4dedcdd13c2c3fd02714ef282b173f7cec7fe..fb02ba609b00d48a8e0e4c127cdc292a438bf9f3 100644 (file)
--- a/commit.c
+++ b/commit.c
+#include "cache.h"
#include "tag.h"
#include "commit.h"
-#include "cache.h"
int save_commit_buffer = 1;
diff --git a/git-compat-util.h b/git-compat-util.h
index c353b276f0464714a4c0220b20df6318a374e28e..12ce6590bb926de2d27eee9520dd2017dd34554e 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
#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>
diff --git a/ls-files.c b/ls-files.c
index cd87430127ee01a473695e21dea4c5d36ed99c46..74ec8c0aeeb52a3bed8a0ac9da8fb9ba5ef66187 100644 (file)
--- a/ls-files.c
+++ b/ls-files.c
struct nond_on_fs {
int len;
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
static struct nond_on_fs **dir;
diff --git a/object.c b/object.c
index cf5931a9423cb2ecdd9f34e6c33ed0b714ce61bf..1577f74281be776082fecebdf8947bcb8c7c6802 100644 (file)
--- a/object.c
+++ b/object.c
+#include "cache.h"
#include "object.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
-#include "cache.h"
#include "tag.h"
struct object **objs;
diff --git a/object.h b/object.h
index 336d986b51831db7812fd9bbd6a818803935fde2..0e7618283cb8c85d89cc2935b8ab7430571a14a7 100644 (file)
--- a/object.h
+++ b/object.h
struct object_refs {
unsigned count;
- struct object *ref[0];
+ struct object *ref[FLEX_ARRAY]; /* more */
};
struct object {
diff --git a/receive-pack.c b/receive-pack.c
index 92878ecac3bdb12efe0d34257852b432558e21f6..ce986fe11cd8989b439f070e9bea5d68b6711758 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
unsigned char updated;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
- char ref_name[0];
+ char ref_name[FLEX_ARRAY]; /* more */
};
static struct command *commands = NULL;
index 61ac434d6b6330e24900beab29c924ccffb886c1..ac0e57398a2b236c9501ac43c517ead371b8988c 100644 (file)
--- a/tag.c
+++ b/tag.c
-#include "tag.h"
#include "cache.h"
+#include "tag.h"
const char *tag_type = "tag";