0

The actual error goes as below,

"tracking.cpp", line 157: Error: Call to 'cppListToWire' is ambiguous.
"/app/sdasup/home/mhp/source/develop/wv/include/cppmarsh.h", line 62: Note, overloadcand: Viable candidate 'void cppListToWire<RWTValSlist<TrackingRec*, std::allocator<TrackingRec*>>>(RWTValSlist<TrackingRec*, std::allocator<TrackingRec*>>&, void*&)'.
"/app/sdasup/home/mhp/source/develop/bc/include/bcMwMrsh.h", line 160: Note, overloadcand: Viable candidate 'void bcMwMrsh::cppListToWire<RWTValSlist<TrackingRec*, std::allocator<TrackingRec*>>>(RWTValSlist<TrackingRec*, std::allocator<TrackingRec*>>&, void*&)'.


"tracking.cpp", line 178: Error: Call to 'cppListToWire' is ambiguous.
"/app/sdasup/home/mhp/source/develop/wv/include/cppmarsh.h", line 62: Note, overloadcand: Viable candidate 'void cppListToWire<RWTValSlist<TrackingSummary*, std::allocator<TrackingSummary*>>>(RWTValSlist<TrackingSummary*, std::allocator<TrackingSummary*>>&, void*&)'.
"/app/sdasup/home/mhp/source/develop/bc/include/bcMwMrsh.h", line 160: Note, overloadcand: Viable candidate 'void bcMwMrsh::cppListToWire<RWTValSlist<TrackingSummary*, std::allocator<TrackingSummary*>>>(RWTValSlist<TrackingSummary*, std::allocator<TrackingSummary*>>&, void*&)'.

This is the example code,

//under bc/include/bcMwMrsh.h
namespace bcMwMrsh
{
    template<typename listT>
        void cppListToWire(listT &src, void *&dest);
)



//under "bc/bcComSupports/bcMwMrsh.cpp
template<typename listT>
void bcMwMrsh::cppListToWire(listT &list, void *&dest)
{
        LOG (LM_MARSHAL_COM, ("    bcMwMrsh::cppListToWire()...\n"));

        int nItems = (int) list.entries();
        bcMwMrsh::cppIntToWire (nItems, dest);
        //RWSlistIterator next(list);
       RWTValSlistIterator<void *> next(list);
        while (next())
          ((AbcObject*)next.key())->toWire(dest);

        LOG (LM_MARSHAL_COM, ("    bcMwMrsh::cppListToWire(): done\n"));
}

 //under wv/include/cppmarsh.h

#ifndef __CPPMARSH_H__
#define __CPPMARSH_H__

template<typename listT>
void cppListToWire(listT &src, void *&dest);

#endif


//under wv/wvCommon/cppmarsh.cpp
     template<typename listT>
     void cppListToWire(listT &list, void *&dest)
     {
      LOG (LM_MARSHAL_COM, ("    cppmarsh::cppListToWire()...\n"));
    
       short nItems = (short) list.entries();
       bcMwMrsh::cppShortToWire(nItems, dest);
       //RWSlistIterator next(list);
       RWTValSlist<void *> next(list);
       while (next())
             ((AISObject*)next.key())->toWire(dest, 0);
    
       LOG (LM_MARSHAL_COM, ("    cppmarsh::cppListToWire(): done\n"));
     }

To eliminate duplication, calls to cppListToWire from cppmarsh been redirected to bcMwMrsh and hence commenting or removing cppListToWire in cppmarsh would clear the error.

However two question one, is it safe to comment/remove the lines from cppmarsh, because you can see nItems in cppmarsh is short as opposed to int in bcMwMrsh?

Second one, is there a way to solve without commenting the cppListToWire under cppmarsh?

Thanks in advance.

Puneeth
  • 419
  • 1
  • 6
  • 18
  • 2
    *"//under "bc/bcComSupports/bcMwMrsh.cpp"* See [why-can-templates-only-be-implemented-in-the-header-file](https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file). – Jarod42 Apr 26 '22 at 11:08
  • 1
    Do you have `using namespace bcMwMrsh;`? Are any of `RWTValSlist`/`TrackingSummary` related to `bcMwMrsh` (in those namespace, or inheriting from type of that namespace)? – Jarod42 Apr 26 '22 at 11:13
  • @jarod42, I had asked this https://stackoverflow.com/questions/71938468/undefined-first-referenced-symbol-in-file-ld-fatal-symbol-referencing-errors and you may see my comment that the implementation of cppListToWire in header file didn't work, unable to get the mistake I might have done during implementation. – Puneeth Apr 26 '22 at 12:29
  • @Jarod42, Yes I do have this using namespace bcMwMrsh;.. RWTValSlist is SourcePro library, and TrackingSummary is a class under wv/include/tracking.cpp > and I dont see any relation with in the namespace or inheritance under bcMwMrsh.h – Puneeth Apr 26 '22 at 13:21
  • If you have `using namespace bcMwMrsh`, `cppListToWire` might indeed refer to `::cppListToWire` or `bcMwMrsh::cppListToWire`. Remove that `using namespace` and it would result in `::cppListToWire`. or full qualify the function (`::cppListToWire`/`bcMwMrsh::cppListToWire`). – Jarod42 Apr 26 '22 at 14:03
  • Removing using namespace bcMwMrsh throws "line 128: Error: The function "cppGuidToWire" must have a prototype." There are several function declared under using namespace bcMwMrsh, and all functions where it is been declared giving the above error. How to handle this at many places? – Puneeth Apr 27 '22 at 04:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/244248/discussion-between-puneeth-and-jarod42). – Puneeth Apr 27 '22 at 05:38

0 Answers0