#include <stdio.h>
#include <windows.h>
struct cpVect
{
float x;
float y;
};
typedef cpVect (*MYPROC)(float);
VOID main(VOID)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("chipmunk-4.0.2.dll"));
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
printf("DLL loaded.\n");
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "cpvforangle");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
cpVect c = (ProcAdd) (1.0);
printf( "\nx: %f\n", c.x);
printf( "\ny: %f\n", c.y);
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("Message via alternative method\n");
}
Belive! C++ version of Puzzle of Mystralia <Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
You can't assume it's a bug in PB because it is working somewhere else ! Try to create a procedure returning a string in PB, create a .lib and import it in C. Now try to call it. It will never work. Is it a C bug ?
We explained what happen, it is NOT supported by PB and will never be as it's C compiler dependant. If this API was designed to be portable and usable everywhere, it fails. Guess what any other major API (Posix, Gtk, Win32, Carbon, etc.) never use this 'feature' ?
IceSoft wrote:Reason:
Look on this C source example it works correct.
Are you using the same compiler to create the DLL as you have used for your example code? If yes, then of course it will work. The calling convention will be the same in both DLL and example.
Returning structures by value from an external DLL would be a nightmare for Fred to support because it depends on something you have no control over and have no standard to aim for. And no (standard) way to find out from a DLL or import lib what was used to create it.