Topic: [Q] purpose of <exception.h> ???
Author: marnold@netcom.com (Matt Arnold)
Date: Thu, 27 Oct 1994 02:51:52 GMT Raw View
dreher@peanuts.Informatik.Uni-Tuebingen.DE (Werner Dreher) writes:
>Hi all,
>I'm trying to compile source developed on Solaris/SunPRO C++ 4.0 and a PowerPC
>AIX 3.2 with xlC 1.2. The source includes a file <exception.h> which is not
>present for xlC. It also uses a predefined exception called xalloc which is
>not defined here either, so I guess it is defined in exception.h.
>What do I have to do to compile code that looks like the following:
> #include <exception.h>
> ...
> class ... {
> public:
>
> int some-member-func() : throw(xalloc);
> }
If your compiler supports exceptions, <exception.h> should have come with
it and should be found in the same place as the other standard includes
such as <stdio.h>, etc..
If your compiler does not support exceptions (which might explain why
you have no <exception.h>) then you will not be able to successfully
compile code that looks like the above. This is because exceptions
require compiler support. The <exception.h> file defines some standard
exceptions, such as xalloc, but is only of any use if you are able to
compile code that uses exceptions.
Do you know if your compiler supports exceptions?
------------------------------------------------------------------------------
Matt Arnold | | ||| | |||| | | | || ||
marnold@netcom.com | | ||| | |||| | | | || ||
Boston, MA | 0 | ||| | |||| | | | || ||
617.389.7384 (H) 617.576.2760 (W) | | ||| | |||| | | | || ||
Windoz..z..Z..Z..e C++/C developer | | ||| 4 3 1 0 8 3 || ||
------------------------------------------------------------------------------
Author: kuhlins@hawk.wifo.uni-mannheim.de (Stefan Kuhlins)
Date: 27 Oct 1994 12:02:13 GMT Raw View
In article <38jf26$6rs@wsiserv.informatik.uni-tuebingen.de> dreher@peanuts.Informatik.Uni-Tuebingen.DE (Werner Dreher) writes:
I'm trying to compile source developed on Solaris/SunPRO C++ 4.0 and a PowerPC
AIX 3.2 with xlC 1.2. The source includes a file <exception.h> which is not
present for xlC. It also uses a predefined exception called xalloc which is
not defined here either, so I guess it is defined in exception.h.
What do I have to do to compile code that looks like the following:
#include <exception.h>
...
class ... {
public:
int some-member-func() : throw(xalloc);
}
In exception.h the classes for exception handling are defined. The SUNPRO
throws an exception of type xalloc if new can't allocate memory.
(Traditionally new returns a null pointer in this case.)
For xlC you can try to change the code: comment out the #include-line and
": throw(xalloc)".
Hope this helps,
Stefan
Author: mendell@opus.torolab.ibm.com (Mark Mendell)
Date: 27 Oct 1994 13:46:47 GMT Raw View
xlC supports exception handling. It does not yet implement the 'new throws an
exception' from a later ANSI C++ draft. In fact, xalloc is not in the latest
draft. Here is a skeleton from the latet draft:
class exception {
public:
exception (const string& what_arg);
virtual ~exception();
virtual string what() const;
protected:
exception();
private:
// const string * desc;
// bool alloced;
};
class runtime_error : public exception {
runtime_error();
~runtime_error();
string what() const;
};
class bad_alloc : public runtime_error {
bad_alloc();
~bad_alloc();
string what() const;
};
// For xalloc use:
class xalloc : public runtime_error {
xalloc();
~xalloc();
string what() const;
};
You may want to replace 'string' with 'char *';
Alternately, you can skip the whole hierarchy, and define:
class xalloc {
public:
exception (const string& what_arg);
virtual ~exception();
virtual string what() const;
protected:
exception();
private:
// const string * desc;
// bool alloced;
};
--
Mark Mendell
C Set ++ for AIX Development
IBM Toronto Lab
mendell@vnet.ibm.com
Author: dreher@peanuts.Informatik.Uni-Tuebingen.DE (Werner Dreher)
Date: 25 Oct 1994 17:25:26 GMT Raw View
Hi all,
I'm trying to compile source developed on Solaris/SunPRO C++ 4.0 and a PowerPC
AIX 3.2 with xlC 1.2. The source includes a file <exception.h> which is not
present for xlC. It also uses a predefined exception called xalloc which is
not defined here either, so I guess it is defined in exception.h.
What do I have to do to compile code that looks like the following:
#include <exception.h>
...
class ... {
public:
int some-member-func() : throw(xalloc);
}
Thank's
=Andrej