Hey guys,
my little programm doesn't seem to work - I assume it is caused by a mistake in the function declaration respectivly calling the function...
The sitation is as follows:
A Programm uses a DLL, respectivly its function EXPORT.
In this function there is a link to another DLL. This one exposes 2 functions - INIT and CTRL, which have the following c-style declarations, using the CDECL calling convention:
Code:
void INIT(double *array1, double *array2);
void CTRL double *array1, double *array2);
Below you find the sourcecode from my DLL, with the function EXPORT:
Code:
#include <stdio.h>
#include <string.h>
#include <windows.h>
typedef void (__cdecl *CTRL)(double*, double*);
typedef void (__cdecl *INIT)(double*, double*);
double dll1_in_array1[101]; //an array for both input and output
double dll1_out_array1[101]; //und for each function
double dll1_in_array2[101]; //these are tranferred to the functions
double dll1_out_array2[101]; //later on
INIT call_dll1_Init;
CTRL call_dll1_Ctrl;
HINSTANCE hinstlib_dll1= LoadLibrary(L"DLL1.dll");
extern "C" {
void __declspec(dllexport) __cdecl EXPORT(float *var1,int *var2, char *var3, char *var4, char *var5);}
void __declspec(dllexport) __cdecl EXPORT(float *var1,int *var2, char *var3, char *var4, char *var5)
{
call_dll1_Init=(INIT)GetProcAddress(hinstlib_dll1,"INIT");
call_dll1_Ctrl=(CTRL)GetProcAddress(hinstlib_dll1,"CTRL");
.
.
.
call_dll1_Init(dll1_in_array1,dll1_out_array1); //calling the functions
call_dll1_Ctrl(dll1_in_array2,dll1_out_array2);
.
.
.
Implementation of the DLL works quite well. calling the functions, e.g.
Code:
call_dll1_Init(dll1_in_array1,dll1_out_array1);
also seems to be working.
But I am quite unsure, if for the cdecl calling convention
Code:
void INIT(double *array1, double *array2);
the declaration
Code:
typedef void (__cdecl *INIT)(double*, double*);
is correct, because
Code:
typedef void (__cdecl *CTRL)(double *input, double *output);
causes no errors in compiling, too.
Thanks for your replies.