error intanstiating template

error intanstiating template

Post by Peter Won » Thu, 04 Apr 2002 03:25:03



Hi,
I'm new to templates and am getting an error which is puzzling.

in a .h file I have declared a template and it's definition:
template <class T> class CStack
{
public:
CStack(char *pName = NULL) {};

Quote:};

in a .c file I have included the above .h file and used the template:
typedef CStack<GrafPtr> PortStack;
PortStack myStack("Port");

The error I'm getting is:
')' expected
(instantiating: 'CStack<GrafPort *>::CStack(char *)')

I'm using CW IDE 4.2.6. Any clues?

Thanks
Peter

--

 
 
 

error intanstiating template

Post by MW Ro » Thu, 04 Apr 2002 05:30:38




Quote:>Hi,
>I'm new to templates and am getting an error which is puzzling.

>in a .h file I have declared a template and it's definition:
>template <class T> class CStack
>{
>public:
>CStack(char *pName = NULL) {};
>};

>in a .c file I have included the above .h file and used the template:
>typedef CStack<GrafPtr> PortStack;
>PortStack myStack("Port");

>The error I'm getting is:
>')' expected
>(instantiating: 'CStack<GrafPort *>::CStack(char *)')

>I'm using CW IDE 4.2.6. Any clues?

It could be that you are doing this as a .c file and activating the C
syntax instead of the C++ compiler.   Turn on the enable C++ compiler in
the target settings for the C/C++ Language options.

If that isn't it, look for the error in a previous headers.  If the code
is the first thing in the source it probably is an error in the last
read header file.

Using this as you showed it worked in a simple example for me.

Ron

--
       TOP PICK   HandHeld Computing - issue 4.5
   "The best overall development tool for the Palm OS"

 Metrowerks, maker of CodeWarrior  -  "Software Starts Here"  


 
 
 

error intanstiating template

Post by Peter Won » Thu, 04 Apr 2002 07:02:30


Hi Ron,
Thanks. It ended up being a problem in the contructor not casting something
correctly. This same code worked fine in VC++ so I assumed it would in
Metrowerks.

Hey, is it possible to use the de* to step into template code? I'm
thinking not but I'm hoping there is a way.  And is there a trick to having
the definition in the cpp file instead of the .h? I'm getting errors when I
put the following in a cpp file instead of the .h file:

template <class T>
CStack<T>::CStack(char *pName)
{
...

Quote:};

Error: illegal empty declaration on the last line "};".

Thanks
Peter




> >Hi,
> >I'm new to templates and am getting an error which is puzzling.

> >in a .h file I have declared a template and it's definition:
> >template <class T> class CStack
> >{
> >public:
> >CStack(char *pName = NULL) {};
> >};

> >in a .c file I have included the above .h file and used the template:
> >typedef CStack<GrafPtr> PortStack;
> >PortStack myStack("Port");

> >The error I'm getting is:
> >')' expected
> >(instantiating: 'CStack<GrafPort *>::CStack(char *)')

> >I'm using CW IDE 4.2.6. Any clues?

> It could be that you are doing this as a .c file and activating the C
> syntax instead of the C++ compiler.   Turn on the enable C++ compiler in
> the target settings for the C/C++ Language options.

> If that isn't it, look for the error in a previous headers.  If the code
> is the first thing in the source it probably is an error in the last
> read header file.

> Using this as you showed it worked in a simple example for me.

> Ron

> --
>        TOP PICK   HandHeld Computing - issue 4.5
>    "The best overall development tool for the Palm OS"

>  Metrowerks, maker of CodeWarrior  -  "Software Starts Here"


--
Peter Wong
Senior Programmer
Inspiration Software, Inc.
The leader in visual learning & thinking

Read more about the numerous awards Inspiration Software, Inc. has received
from teachers, educational magazines and computer learning labs:
http://www.veryComputer.com/

(503) 877-4292 Extension 177
(503) 297-4676 (Fax)
7412 SW Beaverton-Hillsdale Highway
Portland, OR 97225-2167

 
 
 

error intanstiating template

Post by Peter Won » Thu, 04 Apr 2002 07:08:23


Hey, I figured out the second part - bonehead thing I did by leaving the ';' in
when copying the methods from within a class declaration .h file to the .cpp
file.


> Hi Ron,
> Thanks. It ended up being a problem in the contructor not casting something
> correctly. This same code worked fine in VC++ so I assumed it would in
> Metrowerks.

> Hey, is it possible to use the de* to step into template code? I'm
> thinking not but I'm hoping there is a way.  And is there a trick to having
> the definition in the cpp file instead of the .h? I'm getting errors when I
> put the following in a cpp file instead of the .h file:

> template <class T>
> CStack<T>::CStack(char *pName)
> {
> ...
> };

> Error: illegal empty declaration on the last line "};".

> Thanks
> Peter




> > >Hi,
> > >I'm new to templates and am getting an error which is puzzling.

> > >in a .h file I have declared a template and it's definition:
> > >template <class T> class CStack
> > >{
> > >public:
> > >CStack(char *pName = NULL) {};
> > >};

> > >in a .c file I have included the above .h file and used the template:
> > >typedef CStack<GrafPtr> PortStack;
> > >PortStack myStack("Port");

> > >The error I'm getting is:
> > >')' expected
> > >(instantiating: 'CStack<GrafPort *>::CStack(char *)')

> > >I'm using CW IDE 4.2.6. Any clues?

> > It could be that you are doing this as a .c file and activating the C
> > syntax instead of the C++ compiler.   Turn on the enable C++ compiler in
> > the target settings for the C/C++ Language options.

> > If that isn't it, look for the error in a previous headers.  If the code
> > is the first thing in the source it probably is an error in the last
> > read header file.

> > Using this as you showed it worked in a simple example for me.

> > Ron

> > --
> >        TOP PICK   HandHeld Computing - issue 4.5
> >    "The best overall development tool for the Palm OS"

> >  Metrowerks, maker of CodeWarrior  -  "Software Starts Here"

> --
> Peter Wong
> Senior Programmer
> Inspiration Software, Inc.
> The leader in visual learning & thinking

> Read more about the numerous awards Inspiration Software, Inc. has received
> from teachers, educational magazines and computer learning labs:
> http://www.veryComputer.com/

> (503) 877-4292 Extension 177
> (503) 297-4676 (Fax)
> 7412 SW Beaverton-Hillsdale Highway
> Portland, OR 97225-2167

--
Peter Wong
Senior Programmer
Inspiration Software, Inc.
The leader in visual learning & thinking

Read more about the numerous awards Inspiration Software, Inc. has received
from teachers, educational magazines and computer learning labs:
http://www.veryComputer.com/

(503) 877-4292 Extension 177
(503) 297-4676 (Fax)
7412 SW Beaverton-Hillsdale Highway
Portland, OR 97225-2167

 
 
 

error intanstiating template

Post by MW Ro » Thu, 04 Apr 2002 07:33:57




Quote:>Thanks. It ended up being a problem in the contructor not casting something
>correctly. This same code worked fine in VC++ so I assumed it would in
>Metrowerks.

We are a much stricter more modern and much more compliant compiler than
VC++ :)  

Quote:>Hey, is it possible to use the de* to step into template code? I'm
>thinking not but I'm hoping there is a way.  

Sure it will do that.  just step into it or put a break point in the
source code.

Ron

--
       TOP PICK   HandHeld Computing - issue 4.5
   "The best overall development tool for the Palm OS"

 Metrowerks, maker of CodeWarrior  -  "Software Starts Here"  

 
 
 

error intanstiating template

Post by Peter Won » Sun, 07 Apr 2002 03:45:50


Hi Ron,
I can debug the template fine in VC++, but when I try it in MW, I step into
assembly code. Any clues on that one?

Thanks
Peter




> >Thanks. It ended up being a problem in the contructor not casting something
> >correctly. This same code worked fine in VC++ so I assumed it would in
> >Metrowerks.

> We are a much stricter more modern and much more compliant compiler than
> VC++ :)

> >Hey, is it possible to use the de* to step into template code? I'm
> >thinking not but I'm hoping there is a way.

> Sure it will do that.  just step into it or put a break point in the
> source code.

> Ron

> --
>        TOP PICK   HandHeld Computing - issue 4.5
>    "The best overall development tool for the Palm OS"

>  Metrowerks, maker of CodeWarrior  -  "Software Starts Here"


 
 
 

error intanstiating template

Post by MW Ro » Mon, 08 Apr 2002 01:27:14




Quote:>Hi Ron,
>I can debug the template fine in VC++, but when I try it in MW, I step into
>assembly code. Any clues on that one?

I'd have to see what it is,  it could be anything from you don't have
the  dot selected under the debug column for that source file to
inlining is enabled.

I'd need an example to try.

Ron

--
       TOP PICK   HandHeld Computing - issue 4.5
   "The best overall development tool for the Palm OS"

 Metrowerks, maker of CodeWarrior  -  "Software Starts Here"  

 
 
 

error intanstiating template

Post by Peter Won » Wed, 10 Apr 2002 09:30:38


Hi Ron,
Dot is selected in debug column, Inline depth set to "Smart", Auto-inline and
Deferred inlining not checked. I can place a red debug dot in the breakpoint
column but when I run, it turns a dull red and doesn't break.

Thanks
Peter




> >Hi Ron,
> >I can debug the template fine in VC++, but when I try it in MW, I step into
> >assembly code. Any clues on that one?

> I'd have to see what it is,  it could be anything from you don't have
> the  dot selected under the debug column for that source file to
> inlining is enabled.

> I'd need an example to try.

> Ron

> --
>        TOP PICK   HandHeld Computing - issue 4.5
>    "The best overall development tool for the Palm OS"

>  Metrowerks, maker of CodeWarrior  -  "Software Starts Here"


 
 
 

1. Error in loading DLL (Error 48) trying to open templates in Excel 5.0

Hello,

I have made some templates and put them to my network subdirectory
accessible to other users of our LAN. Some users get the message "Error
in loading DLL (Error 48)" when trying to open these templates. Any idea
what this is about? Perhaps something to do with the AutoFilter buttons
and/or buttons with macros assigned to them?

Raino Lampinen

2. Apple IIc

3. Template compilation error: virtual memory exhausted

4. IE icon

5. Error building standalone vxWorks image with templates - makeSymTbl

6. New on Comp.binaries.apple2

7. Quark X-press 4.1 errors using libraries and style templates

8. DTED map file for ilog object wanted

9. error when configuring postgresql7.4 -> ./src/template/linux

10. why do I get an error message using template?

11. reproducable internal compiler error with friend template class declaration of unrelated classes

12. template causing link error

13. Default Compound Template Template-Parameters in C++