Fix structure initialize.
authorManuele conti <conti.ma@alice.it>
Tue, 12 Jun 2012 09:45:31 +0200
changeset 582 8495119e7271
parent 581 1e158dc9f9c1
child 583 e1df3781be84
Fix structure initialize.
lib/iec_std_lib.h
stage4/generate_c/generate_c_vardecl.cc
--- a/lib/iec_std_lib.h	Mon Jun 11 22:38:36 2012 +0200
+++ b/lib/iec_std_lib.h	Tue Jun 12 09:45:31 2012 +0200
@@ -81,28 +81,28 @@
 #endif
 
 
-#define __lit(type,value,sfx) (type)value##sfx
-// Keep this macro expention step to let sfx change into L or LL
-#define __literal(type,value,sfx) __lit(type,value,sfx)
-
-#define __BOOL_LITERAL(value) __literal(BOOL,value,)
-#define __SINT_LITERAL(value) __literal(SINT,value,)
-#define __INT_LITERAL(value) __literal(INT,value,)
+#define __lit(type,value,...) (type)value##__VA_ARGS__
+// Keep this macro expention step to let sfx(__VA_ARGS__) change into L or LL
+#define __literal(type,value,...) __lit(type,value,##__VA_ARGS__##)
+
+#define __BOOL_LITERAL(value) __literal(BOOL,value)
+#define __SINT_LITERAL(value) __literal(SINT,value)
+#define __INT_LITERAL(value) __literal(INT,value)
 #define __DINT_LITERAL(value) __literal(DINT,value,__32b_sufix)
 #define __LINT_LITERAL(value) __literal(LINT,value,__64b_sufix)
-#define __USINT_LITERAL(value) __literal(USINT,value,)
-#define __UINT_LITERAL(value) __literal(UINT,value,)
+#define __USINT_LITERAL(value) __literal(USINT,value)
+#define __UINT_LITERAL(value) __literal(UINT,value)
 #define __UDINT_LITERAL(value) __literal(UDINT,value,__32b_sufix)
 #define __ULINT_LITERAL(value) __literal(ULINT,value,__64b_sufix)
 #define __REAL_LITERAL(value) __literal(REAL,value,__32b_sufix)
 #define __LREAL_LITERAL(value) __literal(LREAL,value,__64b_sufix)
-#define __TIME_LITERAL(value) __literal(TIME,value,)
-#define __DATE_LITERAL(value) __literal(DATE,value,)
-#define __TOD_LITERAL(value) __literal(TOD,value,)
-#define __DT_LITERAL(value) __literal(DT,value,)
-#define __STRING_LITERAL(count,value) (STRING){count,value}
-#define __BYTE_LITERAL(value) __literal(BYTE,value,)
-#define __WORD_LITERAL(value) __literal(WORD,value,)
+#define __TIME_LITERAL(value) __literal(TIME,value)
+#define __DATE_LITERAL(value) __literal(DATE,value)
+#define __TOD_LITERAL(value) __literal(TOD,value)
+#define __DT_LITERAL(value) __literal(DT,value)
+#define __STRING_LITERAL(count,value) {count,value}
+#define __BYTE_LITERAL(value) __literal(BYTE,value)
+#define __WORD_LITERAL(value) __literal(WORD,value)
 #define __DWORD_LITERAL(value) __literal(DWORD,value,__32b_sufix)
 #define __LWORD_LITERAL(value) __literal(LWORD,value,__64b_sufix)
 
--- a/stage4/generate_c/generate_c_vardecl.cc	Mon Jun 11 22:38:36 2012 +0200
+++ b/stage4/generate_c/generate_c_vardecl.cc	Tue Jun 12 09:45:31 2012 +0200
@@ -1597,7 +1597,7 @@
 }
 
 void *visit(structure_element_initialization_list_c *symbol) {
-  if (wanted_varformat == localinit_vf) {
+  if (wanted_varformat == localinit_vf || wanted_varformat == constructorinit_vf) {
     generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o);
     structure_initialization->init_structure_default(this->current_var_type_symbol);
     structure_initialization->init_structure_values(this->current_var_init_symbol);