callback and forth with C
BlitzMax Forums/BlitzMax Programming/callback and forth with C
| ||
was messing around with C and blitzmax thought someone might find this useful... callback.bmx Strict Import "./callb.c" Extern "C" Function RegisterCallback ( fp:Byte Ptr ) Function CallMe (a:Int) End Extern RegisterCallback( Test ) Local r:Int r=callme(1) Print "r="+r Function Test:Int( a:Int ) Print "call back a="+a Return a+1 End Function callb.c int (*callback)(int *); void RegisterCallback ( int *infunc ) { (int)callback = infunc; } int CallMe( int a){ a=callback((int*)a); printf("in C a=%i\n",a); return a+1; } outputs call back a=1 in C a=2 r=3 |