Article View: gnu.gcc.help
Article #52909How to avoid
From: Jonathan M. Cameron
Date: Fri, 01 May 1992 19:47
Date: Fri, 01 May 1992 19:47
91 lines
3049 bytes
3049 bytes
I'm using templates with gcc-2.1 on a Sun SparcStation IPC and having
a minor problem (probably not a bug). I'm getting an error warning
that I want to get rid of. If it is a valid error, I'd like to know
what the problem is and how I can fix it. If it isn't an error in my
code, I'd like to know how to make gcc suppress that warning message
(if possible). The following example is from Stroustrup (2nd edition)
with a few trivial modifications. When I try to compile it, I get the
following warning (although it runs fine.)
make -k
gcc -g -o stack stack.cc -I/usr/local/include/g++ -L/usr/local/lib -lg++
stack.cc: In function `int main ()':
stack.cc:47: warning: dbx info for template class methods not yet supported
Thanks.
-Jonathan Cameron
-------------------------------------------------------------
Jonathan M. Cameron | 36984 Georgia Tech Station
Office: 404-894-8165 | Atlanta, Georgia 30332
Home: 404-676-9008 | EMail: jmc@euler.marc.gatech.edu
=========================== stack.cc ==================================
#include <iostream.h>
template<class T>
class stack
{
public:
stack(int new_size)
{ v = p = new T[_size = new_size]; }
~stack()
{ delete [] v; }
void push(T a)
{
if (p-v < _size)
*p++ = a;
else
cout << "push: Error, unable to push, no room left on the stack\n";
}
T pop()
{
if (p-v > 0)
return *--p;
else {
cout << "pop: Error, unable to pop, nothing is on the stack\n";
return 0;
}
}
int size() const
{ return p-v; }
int room() const
{ return (_size - (p-v)); }
private:
T* v;
T* p;
int _size;
};
main ()
{
stack<int> sint(4);
cout << "Maximum stack size = " << sint.room() << "\n";
cout << "Current stack size = " << sint.size() << "\n";
cout << "Pushing: 1 2 3 4\n";
sint.push(1);
sint.push(2);
sint.push(3);
sint.push(4);
cout << "Room left on stack = " << sint.room() << "\n";
cout << "Trying to push 5: (should be an error)\n";
sint.push(5);
cout << "Popping: ";
cout << sint.pop() << " ";
cout << sint.pop() << " ";
cout << sint.pop() << " ";
cout << sint.pop() << " ";
cout << "\n";
cout << "Current stack size = " << sint.size() << "\n";
cout << "Trying to pop one more: (should be an error)\n";
int i = sint.pop();
}
Technical Details
Message-ID:
<9205011947.AA10891@euler>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!euler.marc.gatech.edu!jmcShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,943f4263f7d2be17,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-05-01 12:47:07 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!euler.marc.gatech.edu!jmc From: jmc@euler.marc.gatech.edu (Jonathan M. Cameron) Subject: How to avoid Message-ID: <9205011947.AA10891@euler> Sender: daemon@cis.ohio-state.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 1 May 1992 19:47:07 GMT Lines: 91