[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cinvoke-dev] Calling a function from a VCL DLL
From: |
Will Weisser |
Subject: |
RE: [cinvoke-dev] Calling a function from a VCL DLL |
Date: |
Mon, 14 Aug 2006 17:30:34 -0500 |
There were two issues here:
1) MyFunc uses the cdecl calling convention, not stdcall.
2) C/Invoke was underflowing the intel fp stack, and apparently VCL
dll's set the fp control register not to ignore stack fault exceptions.
As of now there is a patch in Subversion to fix #2, but I know you can't
compile C/Invoke from source right now because you don't have VC++, so
when I get home I'll work on getting you a new .dll.
-W.W.
-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Shmuel Zeigerman
Sent: Monday, August 14, 2006 5:55 AM
To: address@hidden
Subject: [cinvoke-dev] Calling a function from a VCL DLL
My installation of C/Invoke (cinvoke.dll + cinvoke_lua.dll)
fails on a DLL (mydll.dll) created by Borland C++ Builder.
* The C/Invoke failure takes place only if 'mydll'
is built with the option "use VCL".
* This same DLL that fails, works fine if used without
C/Invoke, i.e. via LoadLibrary() and GetProcAddress().
* Debugging shows that something incorrect takes place in
the function cinv_function_invoke. It's being called,
returns and shortly after that the programs crashes.
* Two debuggers gave the following messages:
a) Project c:\exe\lua.exe faulted with message:
'floating point stack check at 0x10002130'.
b) Program received signal SIGFPE, Arithmetic Exception.
Here's the C and Lua codes:
// unit1.cpp
#include <vcl.h>
extern "C" __declspec(dllexport)
int __stdcall MyFunc(void)
{
return 2006;
}
-- test1.lua
require ("cinvoke_lua")
lib = clibrary.new ("mydll", "stdcall")
MyFunc = lib:get_function (Cint, "MyFunc")
print (MyFunc ())
--
Shmuel
_______________________________________________
cinvoke-dev mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/cinvoke-dev