C++ exceptions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
c0x
Member
Member
Posts: 26
Joined: Sun Apr 20, 2008 2:16 am

C++ exceptions

Post by c0x »

Hi!

I just tried to use C++ exceptions in one of my userland applications and I have a little problem...

First of all a few words about the environment. I'm using my default linux GCC and G++ to compile all executables of my OS. The command line parameters for the compiler are the following:

Code: Select all

-c -march=i686 -O2 -Wall -m32 -fno-strict-aliasing -nostdinc -nodefaultlibs -nostdlib -fno-builtin
I'm not using -fno-exceptions or -no-rtti anywhere. I've a previously created libstdc++.a that runs on my OS and I'm linking this file statically with the C++ executables that runs on my OS.

I just created a little application and I called a function that throws an exception. I'm sure that the exception is thrown because the application exits in the middle of the execution. The funny thing is that the call to the function that throws the exception is surrounded with a try { } catch ( ... ) { print() } block.

I'd like to ask some help in finding out why the exception handler catch is not reached and the exception is handled like a non-caught exception?

Thanks, c0x
User avatar
Adek336
Member
Member
Posts: 129
Joined: Thu May 12, 2005 11:00 pm
Location: Kabaty, Warszawa
Contact:

Re: C++ exceptions

Post by Adek336 »

Probably it's due to the runtime you wrote. You have the whole unwinding and etc stuff?
c0x
Member
Member
Posts: 26
Joined: Sun Apr 20, 2008 2:16 am

Re: C++ exceptions

Post by c0x »

I think that the stack unwinding is provided by the libraries that comes from the GCC such as libstdc++.a and libgcc+a.
As i didn't wrote any unwinding stuff and i didn't get any undefined symbol at linking i think these are implemented in the above mentioned libraries :)

So... any ideas?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: C++ exceptions

Post by Solar »

That your linker doesn't complain seems to indicate you indeed linked the appropriate library parts.

But - and I ask this being ignorant of virtually all the details of C++ environment initialization - do you execute all required set-up steps when loading your executable?
Every good solution is obvious once you've found it.
Post Reply