[omniORB] Problem: no matching function for call to CosNaming::BindingList_var::length()

Stefan Seefeld seefeld@sympatico.ca
Thu, 14 Feb 2002 16:42:04 -0500


Dan Kegel wrote:


>         CorbaPlatoon_var *platoons = new CorbaPlatoon_var[bl.length()];
>                                                           ^^^^^^^^^^^
> 
> This code is taken fairly closely from "Advanced Corba Programming with C++".


fairly closely, but certainly not identical :-)

> What gives?  Hopefully I just made some newbie mistake.


<>_var types are not allocated on the heap. They are meant to be used as
smart pointers themselfs. Assuming CorbaPlatoon is a sequence, you 
allocate it like

CorbaPlatoon_var platoons = new CorbaPlatoon();

this line differs in some important ways from yours:

* platoons is a stack object, not a pointer, even though it is
   constructed with a pointer to a real sequence (which it 'consumes').

* you don't access the length of bl the way you do, but instead you
   dereference the sequence first. Read: bl->length() instead of
   bl.length(). (Again, don't let the fact that the sequence is wrapped
   by a smart pointer fool you !)

* the length argument to the sequence's constructor isn't doing what you
   (probably) expect it to do. It reserves some memory, it doesn't set
   the actual length. You should call

   platoons->length(bl->length());

   explicitely to set the length. (The constructor argument is optional)

> Should I rebuild Omniorb and my app with gcc3?


I think things will work out without that ;-)

Good luck,
		Stefan