C++ in GLbasic

Previous topic - Next topic

mentalthink

Hi, there.

After a time using GLBASIC, (itÃ,´s wonderful), I wish add code in C++ because I want to learn this lenguaje too.
My fisrt dout about to implement C++ on GLbasic, is, how Can make a #include, Ex (Stdio.h)?Ã,¿

I put a little code  like this.

//the code donÃ,´t make nothing only increment a var a (I think...)
WHILE TRUE
INLINE
   
         #include <stdio.h> //this dont work
   
   int a;
   a++;
         ENDINLINE
SHOWSCREEN
WEND

the file.h, I think is called library or headers, is added to source code of my code, but when I try to compile, GLbasic tell me an error about the .h file added.

Another question, I can make anything in c++ into glbasic.?Ã,¿

Thanks, best regards, and happy Christmas!!! for all members of GLB forum

Best Regards,
mentalthink

namco

See the Requre and Import functions in the help file (F1).

MrTAToad

#2
#Include works fine, but only seems to look in the directory that the project is in - which is a problem at times.  You need to download the platform header files to use stdio.h

You can use extern "C" to get access to most stuff, or you can use REQUIRE, IMPORT or the DLL call functions

mentalthink

 Thanks MrTAToad, always give a good answer.

Thanks again.

Best Regards.

Schranz0r

First you have to create a new file on your Project ( right window on your IDE -> Files -> Rightclick on the window -> new file )

Then you have to close the GLBasic-Namespace, and then you can include files ;)


Code (glbasic) Select

INLINE
}  // Close the GLBasic-namespace


#include <stdio.h>


namespace __GLBASIC__{ // restore GLBasic-namespace
ENDINLINE


I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard