This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Is This Really A Parse Error?


EGCS ML,

I've hunted all over the documentation in an effort to clarify this
problem but have found none.  The compile claims that this snippet of
psuedo-code is a parsing error...

template <class V,class K>
KeyedVec<V,K>::getIndex(const K& k)
{
    ...
    static Hasher<V,K> hash(V(),K(),this);  // Compiler says this is a
                                            // error.
    ...
}

The compiler error says...

keyedvec.cpp:82: type specifier omitted for parameter
keyedvec.cpp:82: parse error before `this'
keyedvec.cpp:82: cannot declare static function inside another function


The way I currently get around this problem is by unfolding the
expression like this...

template <class V,class K>
KeyedVec<V,K>::getIndex(const K& k)
{
    ...
    V vv;
    K kk;
    static Hasher<V,K> hash(vv,kk,this);    // this seems to work.
    ...
}

Shouldn't the compiler be able to handle the syntax out of the
first snippet?

Thanks,
Tom Larsen
aka tomar@eai.com

-- 
Tom Larsen(Tomar)  
aka: tomar@eai.com 
      E.A.I        
http://www.eai.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]