I have a program that calls a function in a dynamically-linked library. All of the function calls work fine, except one.
double *frameData = NULL;
int frameDataSize = 0;
g_BeamGage_GetSingleFrame(BEAMGAGE_ID, &frameData, &frameDataSize); //error here
When BeamGage_GetSingleFrame is called when debugging my program, I get a runtime error: (Line 197, col 17 is the position of this function call)
FATAL RUN-TIME ERROR: "BeamGage Interface Test.c", line 197, col 17, thread id 0x00001724: The program has caused a 'Unknown' fault at 001B:7C812AFB.
I encountered this error before, when I was trying to use a NULL function pointer, but when using GetProcAddress, I check to make sure that the pointer is not NULL.
#define BEAMGAGE_FUNCTION_GETSINGLEFRAME "BeamGage_GetSingleFrame"
typedef int(*dataFunc)(const char*, double**, int*);
dataFunc g_BeamGage_GetSingleFrame = NULL;
in main:
... //Load DLL, get other function pointers
g_BeamGage_GetSingleFrame = (dataFunc)GetProcAddress(hBGDll, BEAMGAGE_FUNCTION_GETSINGLEFRAME);
if(g_BeamGage_GetSingleFrame == NULL) {
... //error handling, program exits
}
... //Get more function pointers
The function is defined in a C++/CLI project:
#define BEAMGAGE_IF __declspec(dllexport) _cdecl
extern "C" {
int BEAMGAGE_IF BeamGage_GetSingleFrame(const char *id, double **dataArray, int *dataSize);
}
I am thoroughly stumped by this one, as the error code is rather unhelpful and the function call causing the error is very similar to the other function calls that cause no errors. The only difference I can think of is that this function takes non-const pointer arguments.
EDIT: Also, the code in the BeamGage_GetSingleFrame function (in the C++/CLI assembly) does not execute when the program tries to call it.