From 1f9581cd9ead15bc6bca7a5fdc74a251716c0896 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 29 Oct 2017 18:28:23 +0000 Subject: [PATCH] SmallC: Fix initialization of static/global pointers It's trivial to add the code generation for this and it's an annoying lack in the compiler. --- Applications/SmallC/sym.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Applications/SmallC/sym.c b/Applications/SmallC/sym.c index 3985ac70..50744aaf 100644 --- a/Applications/SmallC/sym.c +++ b/Applications/SmallC/sym.c @@ -195,8 +195,17 @@ void struct_init(TAG_SYMBOL *tag, char *symbol_name) { */ int init(char *symbol_name, int type, int identity, int *dim, TAG_SYMBOL *tag) { int value, n; + + /* A pointer is initialized as a word holding the address of the struct + or string etc that directly follows */ if(identity == POINTER) { - error("cannot assign to pointer"); + int x = getlabel(); + gen_def_word(); + print_label(x); + newline(); + print_label(x); + output_label_terminator(); + newline(); } /* FIXME: may need to distinguish const string v data in future */ if(quoted_string(&n, NULL)) { -- 2.34.1