Making use of Trucidare's awesome iBluetooth wrapper, I noticed that in the IDE, the following line:
IMPORT "C" const char* GLB_iBT_Recv()
'Creates' a new function in the IDE called "char*" rather than GLB_iBT_Recv().
Similarly this is recognised as importing 'int':
IMPORT "C" long int hello()
There doesn't seem to be any problems when compiling, but somewhere in its code the IDE needs to recognise that the last 'word' is the function rather than the next word after the first type-specifying keyword.
Uhm.. I didn't understand that fully now :/
Sorry :whistle:
If I type in the IDE something like:
IMPORT "C" int MyFunction()
... then 'MyFunction()' is recognised in the IDE, put in the 'Jumps' list, highlighted, etc.
However, if the type is more than one word long e.g.:
IMPORT "C" const char* MyString()
IMPORT "C" long int MyInt()
Then instead of recognising "MyString()" and "MyInt()", the IDE recognises "char*" and "int" as functions!
The implications of this aren't that drastic, but it shouldn't be too hard to fix?
ATM the IDE recognises the word after the first type defining one as the function whereas it needs to look for the last word in the line before the '()'.
Hopefully I'm more understandable now. Please let me know if I'm not :S
when you return char*, only?
I mean, the const is ignored anyway.
I mean in the IDE, if you look in the jumps list "char*" is listed as a function! And not "MyString()" :( Try entering the example IMPORTs I gave and you'll see what I mean...
Sry for the confusion.
Doh! I got it. I'll fix that.
But please write:
IMPORT "C" char* MyString2()
and everything is fine.
Oh doesn't const mean anything then anyway? My skills in C++ are somewhat lacking :whistle:
Anyway, thanks. :good:
const char* means, you cannot change the contents the pointer points to. GLBasic, however, using IMPORT will convert your char*/const char* to a DGStr string, thus making a copy of your data anyway. It's safe.
What you have to be aware of is, that returning a char* requires a valid memory buffer that is still alive after the function returns.