[omniORB] Conversion warning for _var types
Chris Newbold
cnewbold@laurelnetworks.com
Fri, 16 Mar 2001 06:43:43 -0500
We're using omniORB 3.02 on Linux with gcc 2.95.2 and have been encountering
warnings like the one below for some time. The source looks something
like this:
// IDL
struct Conduit { ... };
interface Interface {
void DoSomething(in Conduit conduit);
};
// C++
Interface_ptr if;
Conduit_var conduit;
if->DoSomething(conduit);
Here's the warning:
build/linux/x86/protocol/mpls-II/rm/ResourceManager.c++:1360: warning:
choosing
`_CORBA_ConstrType_Variable_Var<xconnect::L2xcCapable::Conduit>::operator
xconne
ct::L2xcCapable::Conduit &()' over
`_CORBA_ConstrType_Variable_Var<xconnect::L2x
cCapable::Conduit>::operator const xconnect::L2xcCapable::Conduit &() const'
build/linux/x86/protocol/mpls-II/rm/ResourceManager.c++:1360: warning: for
con
version from
`_CORBA_ConstrType_Variable_Var<xconnect::L2xcCapable::Conduit>' to
`const xconnect::L2xcCapable::Conduit &'
build/linux/x86/protocol/mpls-II/rm/ResourceManager.c++:1360: warning:
because
conversion sequence for the argument is better
cons: *** [build/linux/x86/protocol/mpls-II/rm/ResourceManager.o] Error 1
To get around this, we have to explicitly cast the _var to a non-const
reference:
if->DoSomething((Conduit&) conduit);
This just doesn't seem right. We do have the compiler warnings turned
up fairly high, but I still think that this code should be okay. Here
are the warning-related flags we're using:
-Werror -Wall -W -Wno-unused -Wpointer-arith -Wbad-function-cast -Wcast-qual
-Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wnested-externs -Woverloaded-virtual
-Chris Newbold
Laurel Networks, Inc.