-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathdoc.h
80 lines (59 loc) · 1.62 KB
/
doc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*! \mainpage SEGVCATCH library documentation
\section about About
This is a crossplatform C++ library designed to convert a hardware exceptions, such as segmentation fault, or floating point errors, into a software language exceptions, which can be handled later with a try/catch construction.
Other words, it's a crossplatform structured exception handling (SEH).
For example, this code is working fine:
\code
try
{
*(int*) 0 = 0;
}
catch (std::exception& e)
{
std::cerr << "Exception catched : " << e.what() << std::endl;
}
\endcode
\section install Installation
<a href="http://www.cmake.org">CMake</a> is required to build project.
Get the sources from http://code.google.com/p/segvcatch. Unpack if needed.
On Linux/Unix you have to:
\verbatim
$ cmake .
$ make
$ sudo make install
\endverbatim
\section using Using
You need to link this library to your project. Then call initializers segvcatch::init_segv(), segvcatch::init_fpe() in a beginning of main() function.
It's a short example:
\code
#include <iostream>
#include <stdexcept>
#include <segvcatch.h>
using namespace std;
int main(int argc, char *argv[])
{
segvcatch::init_segv();
segvcatch::init_fpe();
try
{
*(int*) 0 = 0;
}
catch (std::exception& e)
{
std::cerr << "Exception catched : " << e.what() << std::endl;
}
try
{
int v = 0;
std::cout << 10 / v << std::endl;
}
catch (std::exception& e)
{
std::cerr << "Exception catched : " << e.what() << std::endl;
}
std::cout << "We are living yet!" << std::endl;
return 0;
}
\endcode
\author Navrocky Vladislav
*/