problem porting my application to new gcc (non-const reference )
Jonathan Wakely
jwakely.gcc@gmail.com
Wed Mar 30 09:36:00 GMT 2011
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?
More information about the Gcc-help
mailing list