GLBasic forum

Main forum => Announcements => Topic started by: Kitty Hello on 2009-Aug-05

Title: import C functions
Post by: Kitty Hello on 2009-Aug-05
GLBasic can now include native C functions and files w/o INLINE:

Main.gbas file
Code (glbasic) Select


REQUIRE "test1.cpp" // advise the compiler to take a cpp file, too

IMPORT "C" int Muh(); // IMPORT is like "extern" in C++. All the rest is the same.

Muh() // call it


test1.cpp
Code (glbasic) Select

#include "glb.h"

extern "C" int Muh()
{
STDOUT("Muh!");
}

Title: Re: import C functions
Post by: Schranz0r on 2009-Aug-05
cooooooooool!
Title: Re: import C functions
Post by: bigsofty on 2009-Aug-05
Excellent Gernot, thank you, could we have a mini tutorial please specifying...


Overall a big  :good: from me!
Title: Re: import C functions
Post by: Quentin on 2009-Aug-05
really good news! top!

@bigsofty
let's try it out :) I hope it's possible to use class definitions within the cpp files
Title: Re: import C functions
Post by: MrTAToad on 2009-Aug-05
It'll make things easier
Title: Re: import C functions
Post by: Kitty Hello on 2009-Aug-05
no structure passing. Make that inline or a wrapper. type conversion is:

int, long, short, char, void* -> DGNat
double, float -> DGInt
int& -> DGNat BYREF
double& -> DGInt BYREF
char*, const char* -> DGStr
Title: Re: import C functions
Post by: Quentin on 2009-Aug-05
is this feature ready for download in Beta Release?
Title: Re: import C functions
Post by: Hatonastick on 2009-Aug-05
Ooooh I like INLINE though!

I like this idea a lot too though. :)  Definitely a cool feature.
Title: Re: import C functions
Post by: Hatonastick on 2009-Aug-06
Quote from: Ocean on 2009-Aug-05
Quote from: Hatonastick on 2009-Aug-05
Ooooh I like INLINE though!

it's not mutually exclusive, so....  :)
Darn, so there's no point ranting, raving and demanding it be put back the way it was then?  =D
Title: Re: import C functions
Post by: Schranz0r on 2009-Aug-07
That IMPORT-Functions need to highlight on the IDE...( and Autocompletion/ see the parameters on the "tooltip" at the bottom of the IDE)

Gernot, realy good work!
I can create my "Menu wrapper" from windows.h with that. (without a DLL and YES i can include <windows.h>... but <iostream> crashs) :)
Works fine  :good:
Title: Re: import C functions
Post by: Hemlos on 2009-Aug-08
The line, which IMPORT is written on, is highlighted blue, with the new black theme.

But the declaration itself(IMPORT), and the declared command words are not highlighted.

Question: This new command import, is it the same thing as setting up an inline?
Title: Re: import C functions
Post by: MrTAToad on 2009-Aug-09
Import allows access to the function included by Require - its somewhat like Declare.
Title: Re: import C functions
Post by: Schranz0r on 2009-Aug-09
@ Hemlos:

http://www.glbasic.com/forum/index.php?topic=3059.msg23907#msg23907
Title: Re: import C functions
Post by: bigsofty on 2009-Aug-18
Quote from: Kitty Hello on 2009-Aug-05
no structure passing. Make that inline or a wrapper. type conversion is:

int, long, short, char, void* -> DGNat
double, float -> DGInt
int& -> DGNat BYREF
double& -> DGInt BYREF
char*, const char* -> DGStr


Whoops missed this reply, thanks Gernot!  =D