1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix for prev commit - get usecache working with clang (fix duplicate symbols)

This commit is contained in:
Joe Conigliaro 2022-02-17 22:24:58 +11:00
parent 6fc654821f
commit 07b15a209a
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1

View File

@ -4308,8 +4308,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
(g.pref.use_cache || (g.pref.build_mode == .build_module && g.module_built != node.mod))
&& !util.should_bundle_module(node.mod) {
'extern '
}
else {
} else {
''
}
mut attributes := ''
@ -4331,20 +4330,21 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
g.definitions.write_string('$visibility_kw$styp $attributes $field.name')
if field.has_expr {
if field.expr.is_literal() && should_init {
g.definitions.write_string(' = ${g.expr_string(field.expr)}; // global')
g.definitions.write_string(' = ${g.expr_string(field.expr)}')
} else {
g.global_init.writeln('\t$field.name = ${g.expr_string(field.expr)}; // global')
}
} else {
default_initializer := g.type_default(field.typ)
if default_initializer == '{0}' && should_init {
g.definitions.writeln(' = {0}; // global')
g.definitions.write_string(' = {0}')
} else {
if field.name !in ['as_cast_type_indexes', 'g_memory_block', 'global_allocator'] {
g.global_init.writeln('\t$field.name = *($styp*)&(($styp[]){${g.type_default(field.typ)}}[0]); // global')
}
}
}
g.definitions.writeln('; // global')
}
}