This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about C++ exceptions and g++
- To: gcc at gcc dot gnu dot org
- Subject: Question about C++ exceptions and g++
- From: Craig Rodrigues <rodrigc at mediaone dot net>
- Date: Fri, 13 Oct 2000 22:26:53 -0400
Hi,
I have some C++ code which uses exceptions which compiles with
gcc 2.95.2 but causes the compiler to give an error with
gcc 2.97 20001005 (experimental).
The code can be reduced to something like:
======================================================================
class Exception;
// Define Exception in another file
typedef Exception foo;
int c(int a)
throw (Exception)
{
return 0;
}
=======================================================================
If this code is in a file, a.cpp, which I compile with:
g++ -c a.cpp
I get the error:
a.cpp:10: invalid use of undefined type `class Exception'
a.cpp:1: forward declaration of `class Exception'
Is gcc 2.97 doing the right thing, or is it being too strict?
The code I have defines Exception in another file (b.cpp), and
a.o and b.o are linked together at the final stage of compilation.
This code seems to compile under gcc 2.95.2 and a few other compilers,
so I was wondering if anyone could clarify this for me.
Thanks.
--
Craig Rodrigues
http://www.gis.net/~craigr
rodrigc@mediaone.net