Mail Archives: djgpp/1999/01/08/08:22:34
On Thu, 31 Dec 1998 10:02:01 +0200 (IST), Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> wrote:
>> I'm using GCC 2.8.1 and I found that, while gxx supports exceptions,
>> gcc doesn't (and I also have to add -lstdcxx). Is this true?
>This cannot possibly be true. Both gcc and gxx are just drivers; the
>actual compiler (which supports exceptions) is cc1plus.exe, and it
>should be invoked by either gcc or gxx to compile C++ programs.
I know, that's why I find it strange.
>The most probable cause of your trouble is some installation snafu.
>For example, you might be mixing executables from different GCC
>versions. Add -v to the compilation/link command switches, and watch
>the versions printed by all compiler passes.
I'll try to include every detail now...
This is exc.cc, an exception testing program:
-----------------------------------------------------------------
#include <iostream>
#include <string>
int main() {
string s = "test";
try {
cout << s.substr(5,2); //this should throw an exception
}
catch(...) {
cout << "exxxception!!";
}
}
-----------------------------------------------------------------
Here is the compiler's output for the command "gcc exc.cc -v
-lstdcxx":
-----------------------------------------------------------------
d:/djgpp/lib/gcc-lib/djgpp\2.81\cpp.exe -lang-c++ -v -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=8 -Dunix
-Di386 -DGO32 -DMSDOS -DDJGPP=2 -DDJGPP_MINOR=1 -D__unix__ -D__i386__
-D__GO32__ -D__MSDOS__ -D__DJGPP__=2 -D__DJGPP_MINOR__=1 -D__unix
-D__i386 -D__GO32 -D__MSDOS -D__DJGPP=2 -D__DJGPP_MINOR=1
-D__EXCEPTIONS exc.cc d:/djgpp/tmp\ccaqrk4g
GNU CPP version 2.8.1 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
d:/djgpp/lang/cxx
d:/djgpp/include
d:/djgpp/lang/cxx
d:/djgpp/lib/gcc-lib/djgpp/2.81/include
d:/djgpp/include
End of search list.
d:/djgpp/lib/gcc-lib/djgpp\2.81\cc1plus.exe d:/djgpp/tmp\ccaqrk4g
-quiet -dumpb
ase exc.cc -version -o d:/djgpp/tmp\ccbqrk4g
GNU C++ version 2.8.1 (djgpp) compiled by GNU C version 2.8.1.
d:/djgpp/bin/as.exe -o d:/djgpp/tmp\cccqrk4g d:/djgpp/tmp\ccbqrk4g
d:/djgpp/bin/ld.exe d:/djgpp/lib/crt0.o -Ld:/djgpp/lib
-Ld:/djgpp/lib/gcc-lib/djgpp\2.81 -Ld:/djgpp/bin -Ld:/djgpp/lib
d:/djgpp/tmp\cccqrk4g -lstdcxx -Tdjgpp.djl -lgcc -lc -lgcc
d:/djgpp/bin/stubify.exe -v a.out
stubify for djgpp V2.X executables, Copyright (C) 1995 DJ Delorie
stubify: a.out -> a.exe
-----------------------------------------------------------------
As you can see, the only version mentioned is 2.8.1.
This is the program's output:
-----------------------------------------------------------------
> a.exe
Abort!
>
-----------------------------------------------------------------
So, the exception seems to be caught by the compiler, not by my
handler.
This is the compiler's output for "gxx exc.cc -v":
-----------------------------------------------------------------
Reading specs from d:/djgpp/lib/gcc-lib/djgpp/2.81/specs
gcc version 2.8.1
d:/djgpp/lib/gcc-lib/djgpp/2.81/cpp.exe -lang-c++ -v -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=8 -Dunix
-Di386 -DGO32 -DMSDOS -DDJGPP=2 -DDJGPP_MINOR=1 -D__unix__ -D__i386__
-D__GO32__ -D__MSDOS__ -D__DJGPP__=2 -D__DJGPP_MINOR__=1 -D__unix
-D__i386 -D__GO32 -D__MSDOS -D__DJGPP=2 -D__DJGPP_MINOR=1
-D__EXCEPTIONS exc.cc d:/djgpp/tmp\ccaqjxah
GNU CPP version 2.8.1 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
d:/djgpp/lang/cxx
d:/djgpp/include
d:/djgpp/lang/cxx
d:/djgpp/lib/gcc-lib/djgpp/2.81/include
d:/djgpp/include
End of search list.
d:/djgpp/lib/gcc-lib/djgpp/2.81/cc1plus.exe d:/djgpp/tmp\ccaqjxah
-quiet -dumpb
ase exc.cc -version -o d:/djgpp/tmp\ccbqjxah
GNU C++ version 2.8.1 (djgpp) compiled by GNU C version 2.8.1.
d:/djgpp/bin/as.exe -o d:/djgpp/tmp\cccqjxah d:/djgpp/tmp\ccbqjxah
d:/djgpp/bin/ld.exe d:/djgpp/lib/gcc-lib/djgpp/2.81/crtf.o
d:/djgpp/lib/crt0.o -Ld:/djgpp/lib/gcc-lib/djgpp/2.81 -Ld:/djgpp/bin
-Ld:/djgpp/lib d:/djgpp/tmp\cccqjxah -lstdcxx -lm -lgcc -lc -lgcc
-Tdjgpp.djl
d:/djgpp/bin/stubify.exe -v a.out
stubify for djgpp V2.X executables, Copyright (C) 1995 DJ Delorie
stubify: a.out -> a.000 -> a.exe
-----------------------------------------------------------------
As you can see, the linker is called with different options (but,
according to the faq, this is normal).
And now, this is the program's output:
-----------------------------------------------------------------
> a.exe
exxxception!!
>
-----------------------------------------------------------------
So now my handler catches the exception.
Why this behaviour? What do I do wrong?
Ciao,
Foggy (foggy(at)flashnet.it)
"Windows 95: 32 bit extension and graphical shell for a 16 bit patch to
an 8 bit operating system originally coded for a 4 bit microprocessor"
- Raw text -