Browse Source

fixed lisp linkage

Giuseppe Manzoni 3 years ago
parent
commit
fd5367ae71
2 changed files with 21 additions and 13 deletions
  1. 1 0
      stage2/High_level_prototypes/lisp/lisp.c
  2. 20 13
      stage2/High_level_prototypes/lisp/lisp.h

+ 1 - 0
stage2/High_level_prototypes/lisp/lisp.c

@@ -15,6 +15,7 @@
  * along with stage0.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define LISP_H__VAR_DEF
 #include "lisp.h"
 #include <stdint.h>
 

+ 20 - 13
stage2/High_level_prototypes/lisp/lisp.h

@@ -55,17 +55,24 @@ typedef struct cell
 
 struct cell* make_cons(struct cell* a, struct cell* b);
 
+
+/* Avoid redefinition. Must be already defined in only one .c*/
+#ifndef LISP_H__VAR_DEF
+#define LISP_H__VAR_DEF extern
+#endif
+
+
 /* Global objects */
-struct cell *all_symbols;
-struct cell *top_env;
-struct cell *nil;
-struct cell *tee;
-struct cell *quote;
-struct cell *s_if;
-struct cell *s_lambda;
-struct cell *s_define;
-struct cell *s_setb;
-struct cell *s_cond;
-struct cell *s_begin;
-struct cell *s_let;
-FILE* output;
+LISP_H__VAR_DEF struct cell *all_symbols;
+LISP_H__VAR_DEF struct cell *top_env;
+LISP_H__VAR_DEF struct cell *nil;
+LISP_H__VAR_DEF struct cell *tee;
+LISP_H__VAR_DEF struct cell *quote;
+LISP_H__VAR_DEF struct cell *s_if;
+LISP_H__VAR_DEF struct cell *s_lambda;
+LISP_H__VAR_DEF struct cell *s_define;
+LISP_H__VAR_DEF struct cell *s_setb;
+LISP_H__VAR_DEF struct cell *s_cond;
+LISP_H__VAR_DEF struct cell *s_begin;
+LISP_H__VAR_DEF struct cell *s_let;
+LISP_H__VAR_DEF FILE* output;