• Advertisement
Sign in to follow this  

Exception handling problem

This topic is 3616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a bit new to programming for Linux so i was suprised that try..catch block didn't catch an exception that was trown when my code was trying to write something to the beginning of RAM. I only saw "SegmentationFault" as program output so i'm wondering how to handle segmentation faults in C++ on Linux. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
In C++ try/catch blocks are only guaranteed to catch C++ exceptions: exceptions thrown with the throw keyword. Segmentation faults are handled with POSIX signals on linux, in particular, SIGSEGV. For more information use man signal.

Share this post


Link to post
Share on other sites
This is the syntax of exception handling in C++.

try
{
}
catch() // Derived class
{
}
catch()
{
}
catch()
{
}

This notation go from specific class to general situation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement