IDE doesn't recognise 'IMPORT'ed functions with more than one word for a type

Previous topic - Next topic

Moebius

Making use of Trucidare's awesome iBluetooth wrapper, I noticed that in the IDE, the following line:
Code (glbasic) Select
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':
Code (glbasic) Select
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.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello


Moebius

Sorry  :whistle:

If I type in the IDE something like:
Code (glbasic) Select
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.:
Code (glbasic) Select
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
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

when you return char*, only?
I mean, the const is ignored anyway.

Moebius

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.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

Doh! I got it. I'll fix that.

But please write:
Code (glbasic) Select

IMPORT "C" char* MyString2()

and everything is fine.

Moebius

Oh doesn't const mean anything then anyway?  My skills in C++ are somewhat lacking  :whistle:
Anyway, thanks.  :good:
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

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.