[LC++]check throws

Lawrence Sim lsim_au at yahoo.com.au
Thu Apr 4 22:46:05 UTC 2002

On Fri, 29 Mar 2002 12:28, Peter Poulsen wrote:
> Is there anyway that I can get the gnu compiler to check for throws
> (like in java). I know that this is not standard C++, but I was
> hoping that GNU could have implemented something anyway.

You can make sure that only specific things are alowed to be thrown, 
using the [throw] keyword as in
	void func ( void ) throw (my_exception, string) { ... }
This would mean that only exceptions that throw my_exception and string 
and unknown exeption can come from here, although while the compiler 
may tell you about [catch]ing an exception that can not be thrown by 
the function, in C style it would not tell you about an exception that 
could be thown not being handled, as you may want the program to crash 
outright. You could easily build / modify a compiler that does this and 
there probably are.

Web: http://www.tne.net.au/wanderer/
'Such is Life' - Ned Kelly, just before he was hanged.

The sun was shining on the sea,
Shining with all his might:
He did his very best to make
The billows smooth and bright --
And this was very odd, because it was
The middle of the night.
		-- Lewis Carroll, "Through the Looking Glass"

More information about the tuxCPProgramming mailing list