Struct in file.c

BlitzMax Forums/BlitzMax Programming/Struct in file.c

Other than the example that comes with Max ?

(see Advanced Topics in the Language Help section)
It's not much, but it gives you an idea of how it works.

Fine if you are writing your own C++ classes, not so easy if you are using someone elses (like in a library or such).

I find myself writing glue code :

glue.cpp
...

extern "C" {
    bool qt_action_isChecked(MaxQAction * action);
}

...

bool qt_action_isChecked(MaxQAction * action) {
	return action->isChecked();
}


...


myprog.bmx
Extern
    Function qt_action_isChecked:Int(action:Byte Ptr)
End Extern

The action Byte Ptr is the pointer to a C++ object, which was created elsewhere using C++ like
MaxQAction * qt_new_Action(void * handle, QWidget * parent) {
	MaxQAction * action = new MaxQAction(handle, parent);
	return action;
}

which is also called from Max...

I'm sure there are other (better) ways to go about it.