This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
problem porting my application to new gcc (non-const reference )
- From: Mahmood Naderan <nt_mahmood at yahoo dot com>
- To: gcc <gcc-help at gcc dot gnu dot org>
- Date: Wed, 30 Mar 2011 01:59:21 -0700 (PDT)
- Subject: problem porting my application to new gcc (non-const reference )
Hi all,
IÂam trying to port my program to new version of gcc. Although it works fine on
gcc 4.1, I get someÂcompilation errors. For example consider this piece of code:
namespace aux_ {
 API::conf_object_t * NewObject_stub(API::conf_class_t * aClass, std::string
const & aName, API::conf_object_t * (&constructor)(API::parse_object_t *) );
} //namespace aux_
I get this error:
error: in passing argument 3 of âFlexus::Sim::API::conf_object_t*
ÂÂ Flexus::Sim::aux_::NewObject_stub(Flexus::Sim::API::conf_class_t*, const
std::string&, Flexus::Sim::API::conf_object_t*
ÂÂ (&)(Flexus::Sim::API::parse_object_t*))â
In another part, I have this code:
typename class_::object_type create(std::string aSimName) {
ÂÂÂÂÂ API::conf_object_t * object = aux_::NewObject_stub(
ÂÂÂÂÂÂÂ const_cast<API::conf_class_t *>( theClass->getSimClass() ), aSimName,
theClass->constructor);
Â
and get this error:
error: invalid initialization of non-const reference of type
ÂÂ âFlexus::Sim::API::conf_object_t* (&)(Flexus::Sim::API::parse_object_t*)â
from a temporary of type
ÂÂ âFlexus::Sim::API::conf_object_t*(Flexus::Sim::API::parse_object_t*)â
I searched for those errors, however I saw some examples about null pointer and
other thingsÂthat are not related to my code. So I wonder how can I resolve
that.
Thanks,Â
// Naderan *Mahmood;