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

Export to shared library #21560

Closed
KingBes opened this issue May 24, 2024 · 1 comment
Closed

Export to shared library #21560

KingBes opened this issue May 24, 2024 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@KingBes
Copy link

KingBes commented May 24, 2024

Describe the bug

v

@[export: 'strdemo']
pub fn strdemo(strs string) string
{
	return strs
}

c

const char* strdemo(const char* str);

Nothing. Nothing in the string

Reproduction Steps

v

@[export: 'strdemo']
pub fn strdemo(strs string) string
{
	return strs
}

Expected Behavior

Return with result

Current Behavior

Export to shared library

Possible Solution

No response

Additional Information/Context

No response

V version

0.5.6

Environment details (OS name and version, etc.)

windows

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@KingBes KingBes added the Bug This tag is applied to issues which reports bugs. label May 24, 2024
@JalonSolov
Copy link
Contributor

A V string is a struct, not a char *. Try changing the code to

@[export: 'strdemo']
pub fn strdemo(strs string) string
{
	return strs.data
}

to return the actual char array from V.

Be very careful not to modify that data in the C code, or you will hose the V string.

@KingBes KingBes closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

2 participants