Call function pointer from max in a c file ?
Archives Forums/Win32 Discussion/Call function pointer from max in a c file ?
| ||
Just wondering if anyone knows if its possible to call a function pointer that is defined in a c file ? tried a few thigns but crashes blitz. (only way i got it to work was make a c wrapper file that has a function that calls the function pointer and max calls the wrapper function.) |
| ||
Untested...'--- c_bit.c --- void (*fp)(); '--- bmx_bit.bmx ---- extern global fp() end extern fp |
| ||
Hi i get this when linking using above method. K:/paint_bmx/.bmx/bpaint.bmx.o(code+0x5b14): undefined reference to `bb_GfxInit' K:/paint_bmx/.bmx/bpaint.bmx.o(code+0x5b2d): undefined reference to `bb_GfxInit' the function pointer in c is defined as const void BBCALL (*GfxInit) ( void ); in bmx its defined like Extern Global GfxInit() End Extern What im trying to do is i have this dll in C from this program i was making in blitzplus . so in max only way i could think of to link to this dll was make a c wrapper. so i setup all the function pointers via getProcAddress in a C file. but only way i can seem to call them right is to make a c function that calls the pointers of the various functions. i want the dll to work as a dll so i can use visual C to debug the c part of it. |
| ||
I dont know why but just outta random chance i tried this in the bmx extern thing . Global GfxInit()="GfxInit" and it seems to work . at least for this function as i set a breakpoint in VC and ran the max program exe from that.. and it did enter the c function. yahoo |
| ||
Hmm, that's odd. Max shouldn't be decorating globals like that! |
| ||
seems to crash after calling a few functions using pointers from blitz to c. it actualy goes in the function b4 it crashes and crashes on the function return. actualy it seems the type is getting messed up after the function call ( maybe something with the stack ? ) this below is line is messes up on but if i comment it out i get crash on the next line ( b.numframes = frames ), which makes me think the address to the b. type is getting screwed. b.drawpic = GfxImageCreate ( b.width, b.height, 1, b.width*4 ) b.numframes = frames ( GfxImageCreate is the thing being called as func pointer to the c dll ) if i make a wrapper function in an included c file it seems to work fine. Gonna try more things to see if this is my fault somehow. |