Setting Types in C

BlitzMax Forums/BlitzMax Programming/Setting Types in C

I ended up using getters/setters for stuff like that, and I use cstring($z) to save messing about with BBString.

cpp...
#include <brl.mod/blitz.mod/blitz.h>
#include <windows.h>

class TTest {
public:

	char* a;
	char* b;
	char* c;

	TTest() {
		a = "Foo";
		b = "Bar";
		c = NULL;
	}

	virtual ~TTest() {
		if(a) delete a;
		if(b) delete b;
		if(c) delete c;
	}
	
	virtual void getTest() {
		if(c) delete c;
		c= new char[255];
		sprintf(c, "%d ms", GetTickCount());
	}
	
	virtual char* getA() {return a;}
	virtual char* getB() {return b;}
	virtual char* getC() {return c;}

};


extern "C" {
	TTest *CreateTTest() {return new TTest;}
	void DestroyTTest(TTest *test) {delete test;}
}


bmx..
SuperStrict

Framework BRL.Blitz

Import "ref.cpp"

Extern "C"

Type TTest
	Method _pad1() ' padding for virtual destructors
	Method _pad2()
	Method getTest()
	Method GetA$z()
	Method GetB$z()
	Method GetC$z()
End Type

Function CreateTTest:TTest()
Function DestroyTTest(test:TTest)

End Extern

Local test:TTest = CreateTTest()

For Local i:Int = 0 Until 1000
	test.getTest()
	DebugLog test.geta() + " " + test.getb() + " " + test.getc()
	Delay 10
Next

DestroyTTest(test)


Maybe not ideal, but it works ;)