Re: problem porting my application to new gcc (non-const reference )

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>Which new version?
4.5

>You don't get this error from the declaration, you get this error
>where you try to call the function, and you haven't shown the call so
>it's difficult to say what the problem is.
Â
You are right. Actually the first error in my previous post (you said the 
declaration) was reported after the second one. However since the code place was 
before the second one, I post it first ! 


The right place of the funcions and errors are shown below (Note that I include 
the definition theClass)

Â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_
Â...

 template <class CppObjectClass >
 class Factory {
ÂÂÂ typedef Class<CppObjectClass> class_;
ÂÂÂ class_ * theClass;
ÂÂÂÂ public:
ÂÂÂ Factory() {
ÂÂÂÂÂ static class_ theStaticClass;
ÂÂÂÂÂ theClass = &theStaticClass;
ÂÂÂ }
ÂÂÂ 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 the errors are:
Â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*)â

Â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*))â


>Is it a static member function?
You mean this part:
ÂÂÂÂÂ static class_ theStaticClass;
ÂÂÂÂÂ theClass = &theStaticClass;

>Does it help if you change the call to use &theClass->constructor instead?
No didn't help. Same error...

Regards,
// Naderan *Mahmood;



----- Original Message ----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
To: Mahmood Naderan <nt_mahmood@xxxxxxxxx>
Cc: gcc <gcc-help@xxxxxxxxxxx>
Sent: Wed, March 30, 2011 1:46:12 PM
Subject: Re: problem porting my application to new gcc (non-const reference )

On 30 March 2011 09:59, Mahmood Naderan wrote:
> Hi all,
> IÂam trying to port my program to new version of gcc.

Which new version?

> 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_

This is a function declaration.

> 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*))â

You don't get this error from the declaration, you get this error
where you try to call the function, and you haven't shown the call so
it's difficult to say what the problem is.

> 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*)â

What is the type of theClass->constructor ?

Is it a static member function?

Does it help if you change the call to use &theClass->constructor instead?




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux