stage4/generate_c/generate_c_st.cc
changeset 1095 36bbd0b64816
parent 1076 efaa818ef637
child 1098 84bbafb4fb26
--- a/stage4/generate_c/generate_c_st.cc	Mon Oct 04 11:29:13 2021 +0200
+++ b/stage4/generate_c/generate_c_st.cc	Wed Nov 24 08:58:58 2021 +0100
@@ -169,8 +169,9 @@
         symbol_c* fb_symbol = NULL,
         symbol_c* fb_value = NULL) {
  
+  unsigned int vartype;
   if (fb_symbol == NULL) {
-    unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
+    vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
     symbol_c *first_nonfb = analyse_variable_c::find_first_nonfb(symbol);
     if (first_nonfb == NULL) ERROR;
     if (vartype == search_var_instance_decl_c::external_vt) {
@@ -186,7 +187,7 @@
       s4o.print(SET_VAR);
   }
   else {
-    unsigned int vartype = search_var_instance_decl->get_vartype(fb_symbol);
+    vartype = search_var_instance_decl->get_vartype(fb_symbol);
     if (vartype == search_var_instance_decl_c::external_vt)
       s4o.print(SET_EXTERNAL_FB);
     else
@@ -195,12 +196,20 @@
   s4o.print("(");
   
   if (fb_symbol != NULL) {
-    print_variable_prefix();
-    // It is my (MJS) conviction that by this time the following will always be true...
-    //   wanted_variablegeneration == expression_vg;
-    fb_symbol->accept(*this);
-    s4o.print(".,");
-    symbol->accept(*this);
+    if (vartype == search_var_instance_decl_c::external_vt){
+        print_variable_prefix();
+        s4o.print(",");
+        fb_symbol->accept(*this);
+        s4o.print("->");
+        symbol->accept(*this);
+    }else{
+        print_variable_prefix();
+        // It is my (MJS) conviction that by this time the following will always be true...
+        //   wanted_variablegeneration == expression_vg;
+        fb_symbol->accept(*this);
+        s4o.print(".,");
+        symbol->accept(*this);
+    }
     s4o.print(",");
     s4o.print(",");    
   } else {