Skip to content

Commit c713ece

Browse files
authored
cgen,cheaders: move _vinit_caller()/_vcleanup_caller() fn declare forword (fix #23496) (#23507)
1 parent 27f637a commit c713ece

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎vlib/v/gen/c/cgen.v‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6287,11 +6287,7 @@ fn (mut g Gen) write_init_function() {
62876287
// provide a constructor/destructor pair, ensuring that all constants
62886288
// are initialized just once, and that they will be freed too.
62896289
// Note: os.args in this case will be [].
6290-
if g.pref.os == .windows {
6291-
g.writeln('// workaround for windows, export _vinit_caller, let dl.open() call it')
6292-
g.writeln('// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!')
6293-
g.writeln('VV_EXPORTED_SYMBOL void _vinit_caller();')
6294-
} else {
6290+
if g.pref.os != .windows {
62956291
g.writeln('__attribute__ ((constructor))')
62966292
}
62976293
g.writeln('void _vinit_caller() {')
@@ -6302,11 +6298,7 @@ fn (mut g Gen) write_init_function() {
63026298
g.writeln('\t_vinit(0,0);')
63036299
g.writeln('}')
63046300

6305-
if g.pref.os == .windows {
6306-
g.writeln('// workaround for windows, export _vcleanup_caller, let dl.close() call it')
6307-
g.writeln('// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!')
6308-
g.writeln('VV_EXPORTED_SYMBOL void _vcleanup_caller();')
6309-
} else {
6301+
if g.pref.os != .windows {
63106302
g.writeln('__attribute__ ((destructor))')
63116303
}
63126304
g.writeln('void _vcleanup_caller() {')

‎vlib/v/gen/c/cheaders.v‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,12 @@ typedef int (*qsort_callback_func)(const void*, const void*);
536536
int load_so(byteptr);
537537
void _vinit(int ___argc, voidptr ___argv);
538538
void _vcleanup(void);
539+
#ifdef _WIN32
540+
// workaround for windows, export _vinit_caller/_vcleanup_caller, let dl.open()/dl.close() call it
541+
// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!
542+
VV_EXPORTED_SYMBOL void _vinit_caller();
543+
VV_EXPORTED_SYMBOL void _vcleanup_caller();
544+
#endif
539545
#define sigaction_size sizeof(sigaction);
540546
#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) )
541547

0 commit comments

Comments
 (0)