How to make globalObject
accessible by callbackFunction
?
I am using a third party library library.h
which has a method libraryFunction
. The output of libraryFunction
is a libraryFunctionOutput
which is passed into the callback function callbackFunction
.
How to pass another object (e.g. globalObject
) for use inside the callback function callbackFunction
?
Unfortunately the third party library is compiled so I cannot make any changes to it.
#include <stdio.h>
#include "library.h"
int callbackFunction(int libraryFunctionOutput):
printf("%s, %d", libraryFunctionOutput, globalObject);
return 1;
int main(int argc, char* argv[])
{
int globalObject = 0;
libraryFunction(callbackFunction);
}
In the documentation, the function is shown as:
int __stdcall libraryFunction(const char* filename,
unsigned int flags,
int userID,
MathrelCallback callbackFunction);
The MathrelCallback
struct is defined as the following:
struct MathrelCallback {MathrelHeader header;
MathrelInfo data;
unsigned int Type;
};