GLBasic pointer question

Previous topic - Next topic


Hello again,

only a small question, is it possible to build a linked list
in glbasic, something like:

Code (glbasic) Select

TYPE element

*element // store the next element in the list..


And then check if this Pointer is NULL?

Or is ist possible to access a c class inside the GLBasic code, without using EXTERN "C" all the time?
Having the abillity to write a linked list in GLBasic would be awesome.


You can use INLINE and put a List into a DGArray, return the Index of it and u can use it in types without having problems.

I've managed to put a wrapper of a c++ Class into a GLBasic Type... it was a try and it works perfectly :)
You can try to wrapp the Linked List into a GLB-TYpe.

I can try to send you an example later today.
I <3 DGArray's :D

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


thanks Schranz0r,

pretty good news for me  :good:

A small example would be greatly appreciated


I tried to create a class in inline, which compiles without errors,

I can create an object of it in INLINE,
and also create a DGArray of the class type.

But when I try to use DIMPUSH() on the DGArray in INLINE, I get countless errors suddenly.

Here is the Global INLINE Code:
Code (glbasic) Select

class SEdgeC{
DGInt x;
DGInt y;
SEdgeC* nextEdge;
SEdgeC( DGInt xN , DGInt yN );
SEdgeC* getNextEdge();
void addNewEdge(DGInt x , DGInt y );
void deleteAll();
SEdgeC::SEdgeC( DGInt xN , DGInt yN ){
x = xN;
y = yN;
nextEdge = NULL;
SEdgeC* SEdgeC::getNextEdge(){
return nextEdge;
void SEdgeC::deleteAll(){
if( nextEdge != NULL ){
delete this;
void SEdgeC::addNewEdge( DGInt xN , DGInt yN ){
if( nextEdge != NULL ){
nextEdge->addNewEdge( xN , yN ); // add nextEdge to my nextEdge, if I allready have one
} else nextEdge = new SEdgeC( xN , yN ); // if not then finally create the new edge
DGArray<SEdgeC> Sectors;

and the local INLINE code I used in my main function:
Code (glbasic) Select

SEdgeC start( 0 , 0 );
start.addNewEdge( 0 , 0 );

this is all working, but when I call
Code (glbasic) Select

I get tons of weird errors, telling me that every statement in the INLINE class is faulty.

Kitty Hello

Oh dear. You need a default constructor (no args).
You need a copy operator and a copy constructor. Take care what you do with the pointer so you don't have dangling pointers and multiple delete calls in the end.
The array is not going to be debugable (V15) this way - that's a bit more complicated.

What are you trying to achieve with this? You really think that a a linked list is faster than an array of types with line-array? It might be, but most times it's not, because the most time consuming usually is allocating memory. And an array has less calls to malloc/new than a linked list.
For very big data you are right, though, since you don't need the copies when you have to re-allocate more memory.