How do determine what is *really* causing your compiler error

Posted by ML on Stack Overflow See other posts from Stack Overflow or by ML
Published on 2010-03-23T21:24:00Z Indexed on 2010/03/23 21:33 UTC
Read the original article Hit count: 328

Filed under:
|
|
|

Hi All,

I am porting a very large code base and I am having more difficulty with old code.

For example, this causes a compiler error:

inline CP_M_ReferenceCounted *
FrAssignRef(CP_M_ReferenceCounted * & to, CP_M_ReferenceCounted * from)
{
    if (from) from->AddReference();
    if (to) to->RemoveReference();
    to = from;
    return to; 
}

The error is: error: expected initializer before '*' token.

How do I know what this is. I looked up inline member functions to be sure I understood and I dont think the inlining is the cause but I am not sure what is.

Another example:

template <class eachClass>
    eachClass FrReferenceIfClass(FxRC * ptr)
    {
        eachClass getObject = dynamic_cast<eachClass>(ptr);
        if (getObject)  getObject->AddReference();
        return getObject;
    }

The error is: error: template declaration of 'eachClass FrReferenceIfClass'

That is all. How do I decide what this is?. I am admittedly rusty with templates.

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates