(Mac)将字符串从VBA传递到Dylib-在C 函数中接收到的空字符串
(Mac) Passing string args from VBA to dylib - empty string received in C++ function
试图从VBA调用C 函数(以Dylib的汇编),然后将字符串传递给其如下 -
.h
extern "C"
{
int func(const char* &str);
}
.cpp
int func(const char* &str)
{
//something something
}
vba
Declare PtrSafe Function func Lib "<LibPath>" (ByRef str As String) As Integer
...
Function outFunc
Dim str As String
str = "Hello"
func (str)
End Function
在调试C 代码时,该函数被正确点击,但是在" str"变量中接收到空字符串。还使用NM实用程序来确认该函数已从Dylib正确暴露。
我认为您的函数参数的类型不正确。我认为,如果将C参数更改为const char* str
并将其定义为ByVal str As String
,则它将起作用。
请参阅https://www.codeproject.com/articles/810282/microsoft-office-vba-t-to-the-macs
相关文章:
- 字符串函数在目标C++上运行时C++返回空
- 字符串函数返回奇怪的值
- 这里的字符串函数是什么意思
- 在字符串函数中抛出'char const*'实例后调用的终止
- 为什么 stl 字符串C++函数有时出错有时会出错?
- 从C++为字符串函数设置_ENV
- 来自 2D 数组的字符串函数
- 返回最长的公共子字符串函数 c ++
- 使用getline和字符串函数C++程序中的分段错误
- 在字符串函数的指针中返回地址
- 字符串函数:strcat()
- 这个子字符串函数有什么问题
- 字符串函数不返回字符串? C++
- 使用向量和字符串函数返回字符串
- 尝试修复一个字符串函数,该函数采用字符串并通过替换一些单词来更改它
- 逐字读取字符数组,无需字符串函数
- 我从我的字符串函数返回到主函数
- 为什么我不能从字符串函数返回字符串数组?
- 如何在不使用字符串函数的情况下在char数组中找到字符串?(C )
- 带有 #include< iostream.h> 的程序允许使用 strlen() 等字符串函数。为什么?