Hey!
I was just playing around with Lite-C when i remembered that Lite-C supports C++ API with Classes (like DirectX9).
The syntax was pretty easy and i made some tests.
My results: You can have classes in Lite-C nativly, but with a different setup as in C++.
So how do i create a class?
Just check this code example:
#include <acknex.h>
typedef struct ITestVtbl
{
int answer;
void sayHello(void *This);
} ITestVtbl;
typedef interface ITest
{
ITestVtbl *lpVtbl;
} ITest;
void ITest_sayHello(ITest *This)
{
printf("Answer to live: %d", This->answer);
}
ITest *ITestNew()
{
ITest *test = sys_malloc(sizeof(ITest));
test->lpVtbl = sys_malloc(sizeof(ITestVtbl));
test->lpVtbl->sayHello = ITest_sayHello;
return test;
}
void main()
{
ITest *test = ITestNew();
test->answer = 42;
test->sayHello();
}
The class name is ITest and you create it with ITestNew().
You can have fields and methods, so have fun with it.
Greetings
Felix