Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen,cheaders: move _vinit_caller()/_vcleanup_caller() fn declare forword #23507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kbkpbot
Copy link
Contributor

@kbkpbot kbkpbot commented Jan 18, 2025

Fix issue #23496

This PR will make V's dll can be called by other program.
But the v function should call _vinit_caller()/_vcleanup_caller() directly....

example:

fn C._vinit_caller()
fn C._vcleanup_caller()

@[export: 'func']
fn func() {
	C._vinit_caller()          // must call first
	println('Begin DLL')
	for i in 0 .. 10 {
		println('${i}')
	}
	println('End DLL')
	C._vcleanup_caller()    // must call last,  note, currently , it is an empty function....
}

Copy link

Connected to Huly®: V_0.6-21936

@spytheman
Copy link
Member

(the CI failure is unrelated and already fixed on master)

Comment on lines +539 to +544
#ifdef _WIN32
// workaround for windows, export _vinit_caller/_vcleanup_caller, let dl.open()/dl.close() call it
// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!
VV_EXPORTED_SYMBOL void _vinit_caller();
VV_EXPORTED_SYMBOL void _vcleanup_caller();
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see, what the benefit of this is, compared to the previous approach, of only generating those lines conditionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants