Lawrence Spector wrote:
Quote:
Base base;
BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base));
boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); //
Compile error
>
Results in this error:
>
1>PythonPassReference.obj : error LNK2019: unresolved external symbol
"class boost::python::api::object __cdecl obj(class
boost::shared_ptr<struct BaseWrap&)" (?obj@@YA?
AVobject@api@python@boost@@AAV?$shared_ptr@UBaseWr ap@@@4@@Z)
referenced in function _main
>
My first thought is somehow that looks like a function declaration
instead of creating an object on the stack and instantiating it. If I
remove the shared_ptr, the error goes away.
>
>
Any tips on how to solve this would be greatly appreciated. I'm
probably overlooking something obvious.
You are overlooking something, but it's not that obvious. Your 'obj'
declaration is similar to
double obj(int(&blah));
Care to parse it? A hint: the parentheses around &blah don't matter.
....
Give up? It's the same as
double obj(int &blah);
Look familiar? It's a function declaration!
How do you prevent this from being treated as a function declaration?
Put extra parentheses around the "argument":
double obj((int(&blah)));
In your case:
boost::python::object obj( (boost::shared_ptr<BaseWrap>(&baseWrap)) );
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask