commit 9f0c6b1818a3dac48845572bb64c250673c41c88
parent e0b2f47525a1dc50a5089d2f472f1b51fbb0b483
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 25 Apr 2014 11:22:05 +0200
Move common declarations to a unique file in a include
directory
Diffstat:
14 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/cc1/Makefile b/cc1/Makefile
@@ -2,7 +2,7 @@
OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \
wrapper.o code.o stmt.o
-CFLAGS += -fno-diagnostics-show-caret -g
+CFLAGS += -I../include
all: cc1
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -1,9 +1,5 @@
-#ifndef CC_H
-#define CC_H
-
-#ifndef __bool_true_and_false_defined
-#include <stdbool.h>
-#endif
+#ifndef CC1_H
+#define CC1_H
struct user_opt {
@@ -16,14 +12,8 @@ struct user_opt {
};
extern struct user_opt options;
-
extern void error(const char *fmt, ...);
-extern void die(const char *fmt, ...);
extern void warn(signed char flag, const char *fmt, ...);
-extern void *xmalloc(size_t size);
-extern void *xcalloc(size_t nmemb, size_t size);
-extern char *xstrdup(const char *s);
-extern void *xrealloc(void *buff, register size_t size);
/* definitions of types */
diff --git a/cc1/code.c b/cc1/code.c
@@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <cc.h>
#include "cc1.h"
char *opcodes[] = {
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -3,7 +3,8 @@
#include <stdint.h>
#include <string.h>
-#include "sizes.h"
+#include <sizes.h>
+#include <cc.h>
#include "cc1.h"
#define ID_EXPECTED 1
diff --git a/cc1/error.c b/cc1/error.c
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <cc.h>
#include "cc1.h"
extern unsigned linenum;
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <cc.h>
#include "cc1.h"
static Symbol *zero, *one;
diff --git a/cc1/lex.c b/cc1/lex.c
@@ -5,8 +5,9 @@
#include <string.h>
#include <ctype.h>
+#include <sizes.h>
+#include <cc.h>
#include "cc1.h"
-#include "sizes.h"
static FILE *yyin;
const char *filename;
diff --git a/cc1/main.c b/cc1/main.c
@@ -1,4 +1,5 @@
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/cc1/stmt.c b/cc1/stmt.c
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <cc.h>
#include "cc1.h"
struct scase {
diff --git a/cc1/symbol.c b/cc1/symbol.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
+#include <cc.h>
#include "cc1.h"
#define NR_SYM_HASH 32
diff --git a/cc1/types.c b/cc1/types.c
@@ -3,7 +3,8 @@
#include <stdlib.h>
#include <string.h>
-#include "sizes.h"
+#include <sizes.h>
+#include <cc.h>
#include "cc1.h"
#define NR_TYPE_HASH 16
diff --git a/cc1/wrapper.c b/cc1/wrapper.c
@@ -1,11 +1,9 @@
#include <stdlib.h>
#include <string.h>
-
#include <stdint.h>
-#include "cc1.h"
-
+#include <cc.h>
static void
out_of_memory(void)
diff --git a/include/cc.h b/include/cc.h
@@ -0,0 +1,15 @@
+
+#ifndef CC_H_
+#define CC_H_
+
+#ifndef __bool_true_and_false_defined
+#include <stdbool.h>
+#endif
+
+extern void die(const char *fmt, ...);
+extern void *xmalloc(size_t size);
+extern void *xcalloc(size_t nmemb, size_t size);
+extern char *xstrdup(const char *s);
+extern void *xrealloc(void *buff, register size_t size);
+
+#endif
+\ No newline at end of file
diff --git a/cc1/sizes.h b/include/sizes.h