Browse Source

Initialise static arrays.

Brucey 2 years ago
parent
commit
cddda4d97b
1 changed files with 21 additions and 1 deletions
  1. 21 1
      ctranslator.bmx

+ 21 - 1
ctranslator.bmx

@@ -497,10 +497,16 @@ Type TCTranslator Extends TTranslator
 				If isStructInit Then 
 				If isStructInit Then 
 					If TArrayType( ty ).isStatic Then
 					If TArrayType( ty ).isStatic Then
 						Local t:String = "{"
 						Local t:String = "{"
+						Local count:Int = 0
 						For Local i:Int = 0 Until Int(TArrayType( ty ).length)
 						For Local i:Int = 0 Until Int(TArrayType( ty ).length)
+							count :+ 1
 							If i Then
 							If i Then
 								t :+ ","
 								t :+ ","
 							End If
 							End If
+							If count = 100 Then
+								t :+ "~n"
+								count = 0
+							End If
 							t :+ TransValue(TArrayType( ty ).elemType, "", True)
 							t :+ TransValue(TArrayType( ty ).elemType, "", True)
 						Next
 						Next
 						Return t + "}"
 						Return t + "}"
@@ -920,7 +926,21 @@ t:+"NULLNULLNULL"
 					Return TransType( decl.ty, decl.munged )+" volatile "+decl.munged + "=" + TransValue(decl.ty, "")
 					Return TransType( decl.ty, decl.munged )+" volatile "+decl.munged + "=" + TransValue(decl.ty, "")
 				Else
 				Else
 					If TArrayType(decl.ty) And TArrayType(decl.ty).isStatic Then
 					If TArrayType(decl.ty) And TArrayType(decl.ty).isStatic Then
-						Return TransType( decl.ty, decl.munged )+" "+decl.munged + "[" + TArrayType(decl.ty).length + "]"
+						Local t:String = TransType( decl.ty, decl.munged )+" "+decl.munged + "[" + TArrayType(decl.ty).length + "]"
+						t :+ "={"
+						Local count:Int
+						For Local i:Int = 0 Until Int(TArrayType( decl.ty ).length)
+							count :+ 1
+							If i Then
+								t :+ ","
+							End If
+							If count = 100 Then
+								t :+ "~n"
+								count = 0
+							End If
+							t :+ TransValue(TArrayType( decl.ty ).elemType, "", True)
+						Next
+						Return t + "}"
 					Else
 					Else
 						Return TransType( decl.ty, decl.munged )+" "+decl.munged + "=" + TransValue(decl.ty, "")
 						Return TransType( decl.ty, decl.munged )+" "+decl.munged + "=" + TransValue(decl.ty, "")
 					End If
 					End If