X

Ricardo Ferreira's Blog

  • July 13, 2013

Upgrading to Coherence for C++ 12.1.2 and The "Ambiguous Compilation Error" in Types Derived From AbstractAggregator


This weekend, I started the migration of some old C++ applications built on top of Coherence for C++ 3.7.1 API to its newest and refreshed version, released a few days ago. Version 12.1.2 introduces a lot of cool changes and features in the Coherence product, not mentioning the improvements done in different areas like installation, WebLogic integration, TCMP, Exabus, REST and Coherence*Extend. If you got yourself interested about those changes and improvements, check out the documentation at the following link, and please join us for the live virtual launch event on July 31st. Registration here.

After a couple hours migrating my projects from the oldest version to the newest, I got surprised with the following compiler message when trying to build the code:

call of overloaded 'Float64Sum(const coherence::lang::TypedHandle<coherence::util::extractor::ReflectionExtractor &)' is ambiguous 

If you are experiencing the same compiler message... don't worry. There is a quick and clean solution for this. This compiler error happens because in the 12.1.2 version of Coherence for C++ API, an overloaded version of the create() factory method was introduced in the types derived from the coherence::util::aggregator::AbstractAggregator class.

Until 3.7.1 version, the only way to instantiate an AbstractAggregator object was passing an instance of an coherence::util::ValueExtractor to its factory method. Now you also have the option to pass an instance of an coherence::lang::String::View. This object should contain the name of the attribute that will be aggregated. Automatically and behind the scenes, the Coherence for C++ API will fabricate an coherence::util::ValueExtractor for you.

In my case, I've changed my code from this:

Float64Sum::Handle scoreAggregator = Float64Sum::create(ReflectionExtractor::create("getScore")); 

To this:

Float64Sum::Handle scoreAggregator = Float64Sum::create("getScore"); 

And my project was able to be completely compiled again, both using the GNU Linux G++ and MS Visual Studio for C++ compilers.

Hope this blog helps you eliminate some hours of code debugging :-)

Join the discussion

Comments ( 3 )
  • Dave Wednesday, August 7, 2013

    Nice post and thanks for explaining the problem and solution.


  • guest Friday, January 31, 2014

    I have a strange compilation error in compiling my application with coherence 12.

    I can compile the following example main which have no problems with coherence 3.7.1:

    #include <coherence/lang/MemberHandle.hpp>

    #include <coherence/net/NamedCache.hpp>

    #include <coherence/net/CacheFactory.hpp>

    #include <coherence/lang/System.hpp>

    using coherence::lang::MemberHandle;

    using coherence::lang::System;

    using coherence::net::NamedCache;

    using coherence::net::CacheFactory;

    int main()

    {

    MemberHandle<NamedCache>* foo = new MemberHandle<NamedCache>( System::common(), CacheFactory::getCache("RealTimeObjectCache@NoDomain") );

    return 0;

    }

    Any Idea?


  • guest Friday, January 31, 2014

    In 12.1.2, there were some encapsulations in the API which causes some compilations problem, more precisely in the way about we handle public references.

    But if in this snippet code what you are trying to do is the retrieval of an distributed cache (eg. NamedCache) so there is a simpler way to do this:

    NamedCache::Handle foo = CacheFactory::getCache("RealTimeObjectCache@NoDomain");

    Hope that helps!

    Sincerely,

    Ricardo Ferreira


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.