DarkAnt,
the problem is that you don't initialize / import the newly defined
module. The attached version works fine for me.
Stefan
--
...ich hab' noch einen Koffer in Berlin...
#include <boost/python.hpp>
#include <string>
struct Unit
{
int health;
std::string name;
std::string type;
std::pair<int,int> coord;
};
namespace bpl = boost::python;
BOOST_PYTHON_MODULE(game)
{
bpl::class_<Unit>("Unit")
.def_readwrite("health", &Unit::health)
.def_readwrite("name", &Unit::name)
.def_readwrite("type", &Unit::type)
.def_readwrite("coord", &Unit::coord)
;
}
int main(int argc, char** argv)
{
PyImport_AppendInittab( "game", &initgame);
Py_Initialize();
bpl::object module = bpl::import("game");
Unit unit1;
unit1.health = 100;
unit1.name = "Tank";
unit1.type = "Armor";
bpl::object foo(unit1);
std::cout << bpl::extract<char const *>(bpl::str(foo)) << std::endl;
}
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig