Mail Archives: djgpp/1999/09/21/19:14:52
On 21 Sep 99, at 10:23, Eduardo M Kalinowski wrote:
> In article <7s0l5p$fpc$1 AT solomon DOT cs DOT rose-hulman DOT edu>,
> "Damian Yerrick" <reply DOT at DOT your DOT own DOT risk AT pineight DOT 8m DOT com> wrote:
>
> > > I was trying to run a C++ program compiled that uses exceptions, but
> > I didn't post the source code.
> >
> > The custom here on comp.os.msdos.djgpp and most other
> > programming newsgroups is to post the smallest code fragment
> > that produces the error. Post your source and we'll fix it. Don't
> > post your source and we won't fix it because we're not psychic
> > and we can't see the problem.
>
> I didn't post the source because I was describing a problem not
> relevant to that specific code, but a general failure. Anyway, here is
> the smallest fragment that will trigger the error:
>
> ---start---
> #include <fstream.h>
>
> int
> main()
> {
> try {
> throw "Test";
> } catch (char *e) {
> cout << "Exception caught: " << e;
> }
>
> return 0;
> }
> ---end---
You are throwing const char * but trying to catch char *
Try catching const char:
catch (const char * e) { cout << "Catched\n"; }
At least worked for me.
Andris
- Raw text -