compiler: fix array initialisation generation for msvc
							parent
							
								
									a9a4032a11
								
							
						
					
					
						commit
						04a200d3d8
					
				|  | @ -275,7 +275,7 @@ pub fn (v mut V) cc_msvc() { | |||
| 
 | ||||
| 	// The C file we are compiling
 | ||||
| 	//a << '"$TmpPath/$v.out_name_c"'
 | ||||
| 	a << '".$v.out_name_c"' | ||||
| 	a << '"$v.out_name_c"' | ||||
| 
 | ||||
| 	// Emily:
 | ||||
| 	// Not all of these are needed (but the compiler should discard them if they are not used)
 | ||||
|  | @ -408,6 +408,11 @@ pub fn (v mut V) cc_msvc() { | |||
| 
 | ||||
| 	cmd := '""$escaped_path\\cl.exe" $args"' | ||||
| 
 | ||||
| 	if v.pref.show_c_cmd || v.pref.is_verbose { | ||||
| 		println('\n==========') | ||||
| 		println(cmd) | ||||
| 	} | ||||
| 
 | ||||
| 	// println('$cmd')
 | ||||
| 
 | ||||
| 	res := os.exec(cmd) or { | ||||
|  |  | |||
|  | @ -2718,6 +2718,7 @@ fn (p mut Parser) array_init() string { | |||
| 	if no_alloc { | ||||
| 		p.next() | ||||
| 	} | ||||
| 
 | ||||
| 	// [1,2,3]!! => [3]int{1,2,3}
 | ||||
| 	is_fixed_size := p.tok == .not | ||||
| 	if is_fixed_size { | ||||
|  | @ -2727,10 +2728,10 @@ fn (p mut Parser) array_init() string { | |||
| 			// If we are defining a const array, we don't need to specify the type:
 | ||||
| 			// `a = {1,2,3}`, not `a = (int[]) {1,2,3}`
 | ||||
| 			if p.inside_const { | ||||
| 				p.cgen.set_placeholder(new_arr_ph, '{ ') | ||||
| 				p.cgen.set_placeholder(new_arr_ph, '{') | ||||
| 			} | ||||
| 			else { | ||||
| 				p.cgen.set_placeholder(new_arr_ph, '($typ[]) { ') | ||||
| 				p.cgen.set_placeholder(new_arr_ph, '($typ[]) {') | ||||
| 			} | ||||
| 		} | ||||
| 		return '[$i]$typ' | ||||
|  | @ -2742,7 +2743,13 @@ fn (p mut Parser) array_init() string { | |||
| 	if no_alloc { | ||||
| 		new_arr += '_no_alloc' | ||||
| 	} | ||||
| 	p.gen(' })') | ||||
| 
 | ||||
| 	if i == 0 { | ||||
| 		p.gen(' 0 })') | ||||
| 	} else { | ||||
| 		p.gen(' })') | ||||
| 	} | ||||
| 
 | ||||
| 	// p.gen('$new_arr($vals.len, $vals.len, sizeof($typ), ($typ[$vals.len]) $c_arr );')
 | ||||
| 	// Need to do this in the second pass, otherwise it goes to the very top of the out.c file
 | ||||
| 	if !p.first_pass() { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue