我发现下面的代码在Qt中加载库,但我不完全理解它是如何工作的。有人可以向我解释:typedef int (*MyPrototype)(int, int);
?用QLibrary加载库
int r1 = 0;
QLibrary library("mathlib.so");
if (!library.load())
out << library.errorString() << endl;
if (library.load())
out << "library loaded" << endl;
typedef int (*MyPrototype)(int, int);
MyPrototype myFunction = (MyPrototype)library.resolve("add");
if (myFunction)
r1 = myFunction(a,b);
else
out << library.errorString() << endl;
它是一个指向函数的指针。 –
因此,我将不得不为我想调用的每个函数执行此操作? –
是的,你将不得不。 –