public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* compile error on template using gcc 3.4.4 that worked for gcc 3.3.x
@ 2007-05-09  3:22 Karl Kobata
  2007-05-09 23:59 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Karl Kobata @ 2007-05-09  3:22 UTC (permalink / raw)
  To: gcc-help


Can anyone help?  Can anyone suggest source code change?

Thanks
karl

________________________________________
From: Karl Kobata [mailto:karl.kobata@syncira.com] 
Sent: Sunday, May 06, 2007 10:45 PM
To: 'gcc-help@gcc.gnu.org'
Subject: compile error on template using gcc 3.4.4


Can anyone help me.  I am getting the error messages below for the source
snippet included.  On the previous version of gcc, this error did not occur.
What defaults were assumed on the previous version of the compiler?
Please help.  Please suggest source changes.

Thanks
karl
============== source that is erroring ===============
36 template<class T> class OutputBuffer : public Buffer<T> {
37 public:
38    virtual int Flush() = 0;
39    virtual int Put(const T& t) { *pt++ = t; return pt >= end ? Flush() :
0; }
40    OutputBuffer(unsigned int sz):Buffer<T>(sz) { pt = base; }
41    OutputBuffer(T* b, unsigned int sz):Buffer<T>(b, sz) { pt = base; }
42    OutputBuffer() { pt = base; }
43    ~OutputBuffer() {}
44 };

========== error messages using gcc 3.4.4 =================
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:39: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:39: error:
`end' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`OutputBuffer<T>::OutputBuffer(unsigned int)':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:40: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:40: error:
`base' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`OutputBuffer<T>::OutputBuffer(T*, unsigned int)':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:41: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:41: error:
`base' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`OutputBuffer<T>::OutputBuffer()':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:42: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:42: error:
`base' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In member
function `virtual int InputBuffer<T>::Get(T&)':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:51: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:51: error:
`end' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`InputBuffer<T>::InputBuffer(unsigned int)':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:53: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:53: error:
`end' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`InputBuffer<T>::InputBuffer(T*, unsigned int)':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:54: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:54: error:
`end' undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h: In constructor
`InputBuffer<T>::InputBuffer()':
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:55: error: `pt'
undeclared (first use this function)
/home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:55: error:
`end' undeclared (first use this function)

========= 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: compile error on template using gcc 3.4.4 that worked for gcc 3.3.x
  2007-05-09  3:22 compile error on template using gcc 3.4.4 that worked for gcc 3.3.x Karl Kobata
@ 2007-05-09 23:59 ` Ian Lance Taylor
  2007-05-11 22:03   ` Karl Kobata
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2007-05-09 23:59 UTC (permalink / raw)
  To: Karl Kobata; +Cc: gcc-help

"Karl Kobata" <karl.kobata@syncira.com> writes:

> ============== source that is erroring ===============
> 36 template<class T> class OutputBuffer : public Buffer<T> {
> 37 public:
> 38    virtual int Flush() = 0;
> 39    virtual int Put(const T& t) { *pt++ = t; return pt >= end ? Flush() :
> 0; }
> 40    OutputBuffer(unsigned int sz):Buffer<T>(sz) { pt = base; }
> 41    OutputBuffer(T* b, unsigned int sz):Buffer<T>(b, sz) { pt = base; }
> 42    OutputBuffer() { pt = base; }
> 43    ~OutputBuffer() {}
> 44 };
> 
> ========== error messages using gcc 3.4.4 =================
> /home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:39: error: `pt'
> undeclared (first use this function)

I don't see any declaration of 'pt' in the above code snippet.

If 'pt' is declared in the base class, then you need to say
"this->pt".  To see why, search the net for "two-phase lookup."  gcc
3.4 implemented a new C++ parser which is much more standards
compliant.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: compile error on template using gcc 3.4.4 that worked for gcc 3.3.x
  2007-05-09 23:59 ` Ian Lance Taylor
@ 2007-05-11 22:03   ` Karl Kobata
  0 siblings, 0 replies; 3+ messages in thread
From: Karl Kobata @ 2007-05-11 22:03 UTC (permalink / raw)
  To: 'Ian Lance Taylor'; +Cc: gcc-help

Ian,

You are correct.  I added "this->".  It corrected the errors I was getting.

Thanks very much.
karl

-----Original Message-----
From: Ian Lance Taylor [mailto:iant@google.com] 
Sent: Wednesday, May 09, 2007 4:59 PM
To: Karl Kobata
Cc: gcc-help@gcc.gnu.org
Subject: Re: compile error on template using gcc 3.4.4 that worked for gcc
3.3.x

"Karl Kobata" <karl.kobata@syncira.com> writes:

> ============== source that is erroring ===============
> 36 template<class T> class OutputBuffer : public Buffer<T> {
> 37 public:
> 38    virtual int Flush() = 0;
> 39    virtual int Put(const T& t) { *pt++ = t; return pt >= end ? Flush()
:
> 0; }
> 40    OutputBuffer(unsigned int sz):Buffer<T>(sz) { pt = base; }
> 41    OutputBuffer(T* b, unsigned int sz):Buffer<T>(b, sz) { pt = base; }
> 42    OutputBuffer() { pt = base; }
> 43    ~OutputBuffer() {}
> 44 };
> 
> ========== error messages using gcc 3.4.4 =================
> /home/AppsTest/MGen/MgenLibrary/aeg/include/generic/buffer.h:39: error:
`pt'
> undeclared (first use this function)

I don't see any declaration of 'pt' in the above code snippet.

If 'pt' is declared in the base class, then you need to say
"this->pt".  To see why, search the net for "two-phase lookup."  gcc
3.4 implemented a new C++ parser which is much more standards
compliant.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-11 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-09  3:22 compile error on template using gcc 3.4.4 that worked for gcc 3.3.x Karl Kobata
2007-05-09 23:59 ` Ian Lance Taylor
2007-05-11 22:03   ` Karl Kobata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).