Connecting Tech Pros Worldwide Help | Site Map

Linker error - VS2005 thinks it's a function declaration?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2007, 06:25 PM
Lawrence Spector
Guest
 
Posts: n/a
Default Linker error - VS2005 thinks it's a function declaration?

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.

In case it helps, here's a few more details.

boost::python::object has the following constructor:

// explicit conversion from any C++ object to Python
template <class T>
explicit object(
T const& x
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
// use some SFINAE to un-confuse MSVC about its
// copy-initialization ambiguity claim.
, typename mpl::if_<is_proxy<T>,int&,int>::type* = 0
# endif
)
: object_base(object_base_initializer(x))
{
}

boost::shared_ptr<Thas the following constructor:

template<class Y>
explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be
complete
{
boost::detail::sp_enable_shared_from_this( pn, p, p );
}

Any tips on how to solve this would be greatly appreciated. I'm
probably overlooking something obvious.

Thanks in advance,

Lawrence


  #2  
Old July 17th, 2007, 06:35 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: Linker error - VS2005 thinks it's a function declaration?

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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.