在Mac VBA中调用dylib函数
Calling dylib functions in Office for Mac VBA
我试图调用一个简单的函数,它存储在一个简单的dylib文件中,从一个简单的Word for Mac宏,
我用Xcode5在OS-X Mountain Lion上创建。dylib,并从Word for Mac 2011中调用它。
首先是libWord.dylib:
Test.h
#ifndef __Word__Test__
#define __Word__Test__
bool testFunc();
#endif
Test.cpp
#include "Test.h"
bool testFunc(){
return true;
}
和宏:
词宏观
Private Declare Function testFunc Lib "/Users/usrName/Documents/libWord.dylib" () As Boolean
Sub TestLibFunc()
Dim b As Boolean
b = testFunc
StatusBar = b
End Sub
宏可以找到dylib(我放在上面的目录中),但是一直抛出:
"运行时错误'453':指定DLL函数未找到"
我也尝试过将函数声明为类的一部分:
class testClass{
static bool testFunc();
}
bool testClass::testFunc(){
return true;
}
,然后尝试使用上面的Declare语句和一个带有别名的语句来调用它:
Private Declare Function testFunc Lib "/Users/usrName/Documents/libWord.dylib" Alias "testClass::testFunc" () As Boolean
我还尝试用":"替换库路径名中的"/",所有这些都给出相同的结果。
那么,我错过了什么?就我所见过的所有例子而言:
Office 2011 for Mac中的VBA Shell功能
在MacOSX中返回字符串到VBA
http://social.msdn.microsoft.com/forums/en us/b060f291 - 0754 - 4 - e85燃料a7b9 e64259e6baad/vba -使用-共享-图书馆-办公室- 2011 mac?forum=isvvba
上面的应该工作(以同样的方式,遥控器应该正好在你离开它的地方)。但显然我一定是做错了什么,任何关于在哪里看的指示都是受欢迎的(越明显和羞辱越好)。
与其查找混乱的名称,我认为最简单的方法是将函数声明包装起来:
extern "C" {
bool testFunc();
}
成功!(呃,一直都是在那里 ?)
本教程简要介绍了从VBA调用.dylib函数的基础知识。
请确保安装了Xcode命令行工具,以便您可以使用nm命令从库中获取符号
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么使用 "this" 指针调用派生成员函数?
- 将对象数组的引用传递给函数
- 函数调用中参数的顺序重要吗
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用不带参数的函数访问结构元素
- 代码在main()中运行,但在函数中出现错误
- 内置函数可查看CPP中的成员变量
- (Mac)将字符串从VBA传递到Dylib-在C 函数中接收到的空字符串
- 在mac上传递c/c++ dylib函数,将指针指向VBA
- 在Mac VBA中调用dylib函数