Leopold Toetsch sent the following bits through the ether:

> Could you try my second proposal?

Sure. The patch I tried is attached, which fixes up a lot of the
warnings. However, I now get:

cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o imcparser.o -c imcparser.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o imclexer.o -c imclexer.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o imc.o -c imc.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o stacks.o -c stacks.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o symreg.o -c symreg.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o instructions.o -c instructions.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o cfg.o -c cfg.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o sets.o -c sets.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o debug.o -c debug.c
cc -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -pipe -fno-common  
-g-I../../include -o anyop.o -c anyop.c
cc -o imcc  imcparser.o imclexer.o imc.o stacks.o symreg.o instructions.o cfg.osets.o 
debug.o anyop.o  ../../platform.o -lm
ld: multiple definitions of symbol _n_spilled
imcparser.o definition of _n_spilled in section (__DATA,__common)
imc.o definition of _n_spilled in section (__DATA,__common)
make: *** [imcc] Error 1

If only I knew more C / linker foo...

Cheers, Leon
-- 
Leon Brocard.............................http://www.astray.com/
scribot.................................http://www.scribot.com/

.... According to my calculations the problem doesn't exist
Index: cfg.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/cfg.h,v
retrieving revision 1.4
diff -u -r1.4 cfg.h
--- cfg.h       27 Aug 2002 06:48:44 -0000      1.4
+++ cfg.h       12 Sep 2002 08:53:47 -0000
@@ -1,6 +1,12 @@
 
 /* Data structures: */
 
+#ifdef MAIN
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+
 /* Two-way linked list of predecessors and successors */
 typedef struct _edge {
     struct _basic_block *from;
@@ -22,9 +28,9 @@
 } Basic_block;
 
 /* Globals: */
-Basic_block **bb_list;
-int n_basic_blocks;
-Set** dominators;
+EXTERN Basic_block **bb_list;
+EXTERN int n_basic_blocks;
+EXTERN Set** dominators;
 
 /* Functions: */
 
Index: imc.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imc.h,v
retrieving revision 1.12
diff -u -r1.12 imc.h
--- imc.h       27 Aug 2002 06:48:44 -0000      1.12
+++ imc.h       12 Sep 2002 08:53:47 -0000
@@ -13,6 +13,12 @@
 #  define EX_UNAVAILABLE 1
 #endif
 
+#ifdef MAIN
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+
 #include "symreg.h"
 #include "instructions.h"
 #include "sets.h"
@@ -47,11 +53,11 @@
 char *str_dup(const char *);
 char *str_cat(const char *, const char *);
 
-int IMCC_DEBUG;
-int IMCC_LIFE_INFO;
-int IMCC_VERBOSE;
-int n_spilled;
-SymReg** interference_graph;
+EXTERN int IMCC_DEBUG;
+EXTERN int IMCC_LIFE_INFO;
+EXTERN int IMCC_VERBOSE;
+EXTERN int n_spilled;
+EXTERN SymReg** interference_graph;
 
 
 
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imcc.y,v
retrieving revision 1.21
diff -u -r1.21 imcc.y
--- imcc.y      6 Sep 2002 07:13:52 -0000       1.21
+++ imcc.y      12 Sep 2002 08:53:47 -0000
@@ -13,8 +13,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
-#include "imc.h"
 #include "anyop.h"
+
+#define MAIN
+#include "imc.h"
 
 #define YYDEBUG 1
 
Index: instructions.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.h,v
retrieving revision 1.6
diff -u -r1.6 instructions.h
--- instructions.h      27 Aug 2002 06:48:44 -0000      1.6
+++ instructions.h      12 Sep 2002 08:53:47 -0000
@@ -1,3 +1,8 @@
+#ifdef MAIN
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
 
 /* Types */
 
@@ -58,5 +63,5 @@
 
 /* Globals */
 
-Instruction* instructions;
+EXTERN Instruction* instructions;
 
Index: symreg.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/symreg.h,v
retrieving revision 1.4
diff -u -r1.4 symreg.h
--- symreg.h    27 Aug 2002 06:48:44 -0000      1.4
+++ symreg.h    12 Sep 2002 08:53:47 -0000
@@ -1,3 +1,8 @@
+#ifdef MAIN
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
 
 /* constants */
 
@@ -61,5 +66,5 @@
 
 /* globals */
 
-SymReg * hash[HASH_SIZE];
-int n_symbols;
+EXTERN SymReg * hash[HASH_SIZE];
+EXTERN int n_symbols;

Reply via email to