mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: when building a shared library, make vinit() a constructor
This commit is contained in:
parent
411868a43a
commit
304258162c
@ -2651,7 +2651,14 @@ fn (mut g Gen) write_init_function() {
|
||||
return
|
||||
}
|
||||
fn_vinit_start_pos := g.out.len
|
||||
needs_constructor := g.pref.is_shared && g.pref.os != .windows
|
||||
if needs_constructor {
|
||||
g.writeln('__attribute__ ((constructor))')
|
||||
g.writeln('void _vinit() {')
|
||||
g.writeln('static bool once = false; if (once) {return;} once = true;')
|
||||
} else {
|
||||
g.writeln('void _vinit() {')
|
||||
}
|
||||
if g.pref.autofree {
|
||||
// Pre-allocate the string buffer
|
||||
// TODO make it configurable
|
||||
|
Loading…
Reference in New Issue
Block a user