[英]Which Smalltalk object should be passed to a C function expecting const char*
I want to call the following C function:我想调用以下C function:
int ssh_userauth_password (ssh_session session, const char * username, const char * password)
But regular Smalltalk strings are not working:但是常规的 Smalltalk 字符串不起作用:
library ssh_login: session userAuth: nil password: 'myPwd'.
session
is a pointer that i already have and works ok. session
是我已经拥有并且工作正常的指针。
But const char *
are not mapped to normal string.但是const char *
没有映射到普通字符串。 Is there any class to map this?有没有 class 到 map 这个? Also i tried with CPointer and asByteArray but both fail.我也尝试使用 CPointer 和 asByteArray 但都失败了。
You need to pass a CPointer object.您需要传递一个 CPointer object。 Easiest way to do that is via 'yay' gcCopyCStringToHeap
.最简单的方法是通过'yay' gcCopyCStringToHeap
。 Alternatively there're variations like gcCopyUnicodeStringToHeap
.或者,还有gcCopyUnicodeStringToHeap
类的变体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.