-
Notifications
You must be signed in to change notification settings - Fork 70
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
Are variadic functions supported? #116
Comments
I should mention I'm using macOS (darwin/arm64). |
That is correct. Variadic functions are not supported and there are currently no plans to add them. |
Thanks for the response. I think the documentation for RegisterFunc/RegisterLibFunc could be improved because that wasn't clear to me. But I'm not sure what to change it to, as there is probably some use for the current arrangement with |
The current implementation is used to implement the Send method in the objc package. This way the user of the method can call any objc method without having to create a func variable, link it to the C function and then call it. |
How do I convert Go []string to C char ** |
Create a slice of *byte. Convert each string to null terminated *byte. Then pass the address of the slice to the function. So the signature would be &slice[0] and the type **byte |
Please understand that I may be a little unclear in the description, for the case of a C function parameter char **, what type should be used in Go? |
**byte like I said |
I'm sorry that I can't solve this matter according to your suggestion
Go:
I'm not sure if that's what you said, but I still haven't gotten the correct data return, The correct result data should be a string, but I only got one byte, what should I do to get the returned string |
You actually got all the code right so far. You just need to turn the *byte back into a string. There's no easy way to do this atm. There's discussion in #121 about making it more accessible. You can also just copy the code that's inside purego/internal/strings. Ofc you'll have to do that for each pointer in the slice EDIT: I don't really want to busy up this issue more as your question doesn't relate to variadic functions. If you have more questions about this please ask on the discord. |
@craig65535 @TotallyGamerJet Unfortunately ffi doesn't support MacOS yet. |
The source has a comment about a special case for variadic functions -
Does this mean they are not supported? I made my own library in C and am unable to find a way to get my function to see any of the variadic parameters.
Calling code:
This prints:
The text was updated successfully, but these errors were encountered: