Passing string to an external C function
BlitzMax Forums/BlitzMax Programming/Passing string to an external C function
| ||
Hi all, I'm having trouble figuring out how to pass a string to an external C function (incidentally in a library). Library's built fine, and I can happily import/link it within BMax. However, it looks like nothing happens. My .bmx looks like: Import "test.a" Extern Function test( url:String ) End Extern test( "Hi there" ) I put test() in test.c below, then $ gcc -c test.c $ ar rc test.a test.o $ ranlib test.a void test( char url[] ) { printf( "%s", "Hi there all, this is a test" ); printf( "%s", url ); } The only thing that appears to stdout is Hi there, this is a test... so: 1. How does one pass a string to an external C function from bmx? 2. Out of interest, why does the C output to stdout appear after the main (GUI) app quits? Any way of setting the buffer to flush immediately a la perl $|=1? Cheers, Tim |
| ||
Try it with :Extern Function test( url$z ) 'what means CString End Extern |
| ||
Nice one k2; that works fine. Are those identifiers documented anywhere? Thanks for the help! |
| ||
Not really, you could see them if you take a closer look to the different module sources. |
| ||
Ok ta, will take a closer look, thanks for the pointers! |
| ||
See my previous post here: http://www.blitzmax.com/Community/posts.php?topic=56160 http://www.blitzmax.com/Community/posts.php?topic=55869 Maybe they could be helpful. |