digitalmars.D.learn - function pointer from DLL
I've been trying to translate the following from http://www.scintilla.org/Steps.html int (*fn)(void*,int,int,int); void * ptr; int canundo; fn = (int (__cdecl *)(void *,int,int,int))SendMessage( hwndScintilla,SCI_GETDIRECTFUNCTION,0,0); ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0); canundo = fn(ptr,SCI_CANUNDO,0,0); And I got a run time error while running 'fn(ptr, SCI_CANUNDO, 0, 0);': int function (void*,int,int,int) fn; fn = cast(int function(void*,int,int,int)) SendMessage( hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0); void *ptr = cast(void *)SendMessage(hwndScintilla, SCI_GETDIRECTPOINTER, 0, 0); fn(ptr, SCI_CANUNDO, 0, 0); Run time error: object.Error: Access Violation Then I've tried extern (C) int function (void*,int,int,int) fn; fn = cast(extern (C) int function(void*,int,int,int))SendMessage( hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0); Compilation error: basic type expected, not extern Could someone point me in the right direction.
Jan 13 2012
On Sat, Jan 14, 2012, at 06:04 AM, Andrej Mitrovic wrote:On 1/14/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:Yeah! Rock'n'roll! Thank you.You can clone this: git github.com:AndrejMitrovic/DSciteWin.git Then just run build.bat.Sorry, I've assumed you run git, the http link is: https://github.com/AndrejMitrovic/DSciteWin
Jan 13 2012