compiler: generate a v.c that is compatible with latest tcc
parent
72ae12877e
commit
9a0a8e89fb
|
@ -40,9 +40,17 @@ CommonCHeaders = '
|
||||||
|
|
||||||
#define EMPTY_STRUCT_DECLARATION
|
#define EMPTY_STRUCT_DECLARATION
|
||||||
#define EMPTY_STRUCT_INITIALIZATION 0
|
#define EMPTY_STRUCT_INITIALIZATION 0
|
||||||
|
// Due to a tcc bug, the length of an array needs to be specified, but GCC crashes if it is...
|
||||||
|
#define EMPTY_ARRAY_OF_ELEMS(x,n) (x[])
|
||||||
|
#define TCCSKIP(x) x
|
||||||
|
|
||||||
#ifdef __TINYC__
|
#ifdef __TINYC__
|
||||||
#undef EMPTY_STRUCT_INITIALIZATION
|
#undef EMPTY_STRUCT_INITIALIZATION
|
||||||
#define EMPTY_STRUCT_INITIALIZATION
|
#define EMPTY_STRUCT_INITIALIZATION
|
||||||
|
#undef EMPTY_ARRAY_OF_ELEMS
|
||||||
|
#define EMPTY_ARRAY_OF_ELEMS(x,n) (x[n])
|
||||||
|
#undef TCCSKIP
|
||||||
|
#define TCCSKIP(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OPTION_CAST(x) (x)
|
#define OPTION_CAST(x) (x)
|
||||||
|
|
|
@ -317,18 +317,15 @@ fn (p mut Parser) gen_array_init(typ string, no_alloc bool, new_arr_ph int, nr_e
|
||||||
if no_alloc {
|
if no_alloc {
|
||||||
new_arr += '_no_alloc'
|
new_arr += '_no_alloc'
|
||||||
}
|
}
|
||||||
if nr_elems == 0 && p.pref.ccompiler != 'tcc' {
|
if nr_elems == 0 {
|
||||||
p.gen(' 0 })')
|
p.gen(' TCCSKIP(0) })')
|
||||||
} else {
|
} else {
|
||||||
p.gen(' })')
|
p.gen(' })')
|
||||||
}
|
}
|
||||||
// Need to do this in the second pass, otherwise it goes to the very top of the out.c file
|
// Need to do this in the second pass, otherwise it goes to the very top of the out.c file
|
||||||
if !p.first_pass() {
|
if !p.first_pass() {
|
||||||
// Due to a tcc bug, the length needs to be specified.
|
|
||||||
// GCC crashes if it is.
|
|
||||||
cast := if p.pref.ccompiler == 'tcc' { '($typ[$nr_elems])' } else { '($typ[])' }
|
|
||||||
p.cgen.set_placeholder(new_arr_ph,
|
p.cgen.set_placeholder(new_arr_ph,
|
||||||
'$new_arr($nr_elems, $nr_elems, sizeof($typ), $cast { ')
|
'$new_arr($nr_elems, $nr_elems, sizeof($typ), EMPTY_ARRAY_OF_ELEMS( $typ, $nr_elems ) { ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue