C Functions and Max
BlitzMax Forums/BlitzMax Programming/C Functions and Max
| ||
| I want to call a C function, do some processing and then return the result to Max. But using the example in the docs the function is undefined according to the error code. Where am I going wrong?
C Code:
int doubler (int x)
{
return x+x;
}
Max code:
Import "c_code.cpp"
Extern
Function doubler (x)
End Extern
Print doubler(10)
|
| ||
| http://www.blitzbasic.com/Community/posts.php?topic=52256#583599 |
| ||
| Thanks! Works fine now. |
| ||
| But that code doesn't seem to work with a C++ file (.cpp) - what's required for C++? Also, if you use a pointer to an array in C++ how do you then return that pointer info into Max to access the array using MAX pointers? |
| ||
| I'd have a look at the irrlicht mod that gman did he wrapped all the C++ stuff in irrlict and it serves as a good example of advanced intergration |
| ||
| Thanks Chris, I'll take a look - sounds a bit involved though. |
| ||
| well thats c++ for you, you'd be FAR far better off doing everthing you possibly can in max... I try and keep all my data structures / variables defined by max, you can always pass values as parameters in functions As for arrays you might want to consider a flat block of memory accessed as a bank. Or better yet rewrite all the c++ code in max... |