locked
Resolving Ambiguous Symbol Error RRS feed

  • Question

  • I use the Interactive Brokers API to help me with my stock trading but I'm having a problem building it on Visual Studio 2010 Beta 2.  The API has its own shared_ptr class and when I compile I now get 381 errors along the lines of:

    1>c:\jts\shared\shared_ptr.h(55): error C2872: 'shared_ptr' : ambiguous symbol
    1>          could be 'c:\jts\shared\shared_ptr.h(50) : shared_ptr'
    1>          or       'c:\program files\microsoft visual studio 10.0\vc\include\memory(1388) : std::tr1::shared_ptr'

    All the errors are in the API code itself rather than in my program.  It builds fine on VS2008 which also has a shared_ptr defined in microsoft visual studio 9.0\vc\include\memory so I'm not sure what's changed.

    Is there a way I can resolve this problem so that it knows to use the Interactive Broker's shared_ptr?

    Thanks for any advice you can offer.
    Sunday, December 6, 2009 3:36 PM

Answers

  • It can be resolved if Brokers API have their shared_ptr inside a namespace.
    If they do, remove the state using namespace xxx and scope it in places where you use the shared_ptr.
    For example,
    Brokers::shared_ptr<> and std::tr1::shared_ptr<>.

    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by Richard797 Sunday, December 6, 2009 4:33 PM
    Sunday, December 6, 2009 4:01 PM

All replies

  • It can be resolved if Brokers API have their shared_ptr inside a namespace.
    If they do, remove the state using namespace xxx and scope it in places where you use the shared_ptr.
    For example,
    Brokers::shared_ptr<> and std::tr1::shared_ptr<>.

    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by Richard797 Sunday, December 6, 2009 4:33 PM
    Sunday, December 6, 2009 4:01 PM
  • Unfortunately it's not in a namespace.  I've renamed it for now and hopefully IB will fix the problem in the next API release.

    I don't really understand why it built in VS2008 but not VS2010 when they both have a shared_ptr defined in \vc\include\memory and thought that perhaps there would be a way to get it working without editing IB's API code, but it's not really a big issue and I'm sure IB will fix it in the future.

    Thanks for your help.

    Sunday, December 6, 2009 4:33 PM
  • I believe IB should be really using the C++ shared_ptr instead of defining their own.
    «_Superman_»
    Microsoft MVP (Visual C++)
    Sunday, December 6, 2009 5:16 PM