mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: use _vinit instead of _init to avoid conflicts on Linux
This commit is contained in:
parent
eb8d64999f
commit
f962d92623
@ -12,7 +12,7 @@ struct Gen {
|
|||||||
out strings.Builder
|
out strings.Builder
|
||||||
typedefs strings.Builder
|
typedefs strings.Builder
|
||||||
definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
|
definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
|
||||||
inits strings.Builder // contents of `void _init(){}`
|
inits strings.Builder // contents of `void _vinit(){}`
|
||||||
table &table.Table
|
table &table.Table
|
||||||
mut:
|
mut:
|
||||||
fn_decl &ast.FnDecl // pointer to the FnDecl we are currently inside otherwise 0
|
fn_decl &ast.FnDecl // pointer to the FnDecl we are currently inside otherwise 0
|
||||||
@ -527,7 +527,7 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
|
|||||||
g.definitions.writeln(');')
|
g.definitions.writeln(');')
|
||||||
}
|
}
|
||||||
if is_main {
|
if is_main {
|
||||||
g.writeln('_init();')
|
g.writeln('_vinit();')
|
||||||
g.writeln('os__args = os__init_os_args(argc, (byteptr*)argv);')
|
g.writeln('os__args = os__init_os_args(argc, (byteptr*)argv);')
|
||||||
}
|
}
|
||||||
for stmt in it.stmts {
|
for stmt in it.stmts {
|
||||||
@ -1463,7 +1463,7 @@ fn (g mut Gen) const_decl(node ast.ConstDecl) {
|
|||||||
g.definitions.writeln(val)
|
g.definitions.writeln(val)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Initialize more complex consts in `void _init(){}`
|
// Initialize more complex consts in `void _vinit(){}`
|
||||||
// (C doesn't allow init expressions that can't be resolved at compile time).
|
// (C doesn't allow init expressions that can't be resolved at compile time).
|
||||||
styp := g.typ(field.typ)
|
styp := g.typ(field.typ)
|
||||||
g.definitions.writeln('$styp $name; // inited later') // = ')
|
g.definitions.writeln('$styp $name; // inited later') // = ')
|
||||||
@ -1555,7 +1555,7 @@ fn verror(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (g mut Gen) write_init_function() {
|
fn (g mut Gen) write_init_function() {
|
||||||
g.writeln('void _init() {')
|
g.writeln('void _vinit() {')
|
||||||
g.writeln(g.inits.str())
|
g.writeln(g.inits.str())
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user