RE: gcc v3.4.4; templates and compile errors

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

 



I have found the fix to this compiler error! I re-read the email sent by Corey once again this morning and found that I missed placing the 1st 'typename' at the beginning of the line. I had only put in the 2nd one, which resulted in an internal compiler error (see my previous reply). 

Once I added that one, I got back to getting compiler errors that I could process through. It turns out that the line will get past the compiler with no warnings if it looks like below (with the 'template' keyword added):

typename SAX::basic_XMLReader<stringT>::template Property<typename SAX::basic_DeclHandler<stringT> *>* prop;


Now, I have one last similiar compile error in this file and hopefully I am home free. Here is the function (with my attempt at fixing it with 'template' and 'typename' and the output:

template<class stringT, class string_adaptorT>
327 void libxml2_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name, typename std::auto_ptr<typename basic_XMLReader<stringT>::PropertyBase> value)
328 {
329   typename SAX::basic_XMLReader<stringT>::template Property<declHandlerT&>* prop;
330   prop = dynamic_cast<SAX::basic_XMLReader<stringT>::template Property<declHandlerT&>*>(value.get());
331
332 ...
333
334   return;
335 }

/saxlibxml2.h:330: error: expected template-id for type before '*' token

I corrected line 329 with the addition of 'typename' and 'template' as it was giving me errors first. But now I can't figure out what combination to do for 330. I have only added the 'template' keyword so far. Previous to that addition, I was getting:

/saxlibxml2.h:330: error: 'class SAX::basic_XMLReader<string_type>::Property' is not a type.

I think this is my last hurdler, hopefully one of you can recommend a solution!

Thanks,

Tom



> -----Original Message-----
> From: corey taylor [mailto:corey.taylor@xxxxxxxxx]
> Sent: Thursday, June 23, 2005 15:36
> To: Magyar, Thomas J. CIV NAVAIR
> Cc: gcc-help@xxxxxxxxxxx
> Subject: Re: gcc v3.4.4; templates and compile errors
> 
> 
> It looks like you're missing a "typename" keyword on that line.
> 
> The reason int works is because that removes the dependency from the
> template parameters.
> 
> typename SAX::basic_XMLReader<stringT>::Property<typename
> SAX::basic_DeclHandler<stringT> *>* prop;
> 
> More information on this whole requirement is under the C++ section
> of: http://gcc.gnu.org/gcc-3.4/changes.html
> 
> corey
> 
> On 6/23/05, Magyar, Thomas J.  CIV NAVAIR 
> <thomas.magyar@xxxxxxxx> wrote:
> > In upgrading from gcc v3.3 to gcc v3.4.4 on an SGI IRIX 
> 6.5, I'm having a compile error that I can not figure out. 
> We're trying to build the SAX library, and in one of the 
> files (saxlibxml2.h) there is a function that a line is 
> giving me an error:
> > 
> > template<class stringT, class string_adapterT>
> > std::auto_ptr<typename 
> basic_XMLReader<stringT>::PropertyBase> 
> libxml2_wrapper<stringT, 
> string_adapterT>::doGetProperty(const stringT& name)
> > {
> >   if(name == properties_.declHandler)
> >   {
> > -->    
> SAX::basic_XMLReader<stringT>::Property<SAX::basic_DeclHandler
> <stringT> *>* prop;
> > 
> >     prop = new 
> SAX::basic_XMLReader<stringT>::Property<SAX::basic_DeclHandler
> <stringT>*>(declHandler_);
> > 
> >     return std::auto_ptr<typename 
> SAX::basic_XMLReader<stringT>::PropertyBase>(prop);
> >   }
> > 
> >   ...
> > }
> > 
> > The line beginning with SAX:: is giving us this compile error:
> > 
> > SAX/wrappers/saxlibxml2.h:310: error: expected 
> primary-expression before '*' token
> > 
> > 
> > Not very helpful really. In playing around with the line of 
> code and trying to narrow it down, I have found out that if I 
> replace all the '<stringT>' in that line (there are 4 
> instances of it) with '<int>' it compiles without warning. 
> But obviously, it won't work as intended. So it is something 
> to do with the 'stringT'. Yet there are other functions in 
> this file that use stringT and with no compile errors.
> > 
> > Does anyone who is good with templates have any ideas in 
> what I may be missing? I'm only familiar with basic 
> templates...this code is what I call template hell!
> > 
> > Thanks,
> > 
> > Tom
> > 
> >
> 


[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