Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
STD_UNCAUGHT_EXCEPTION.cpp
Go to the documentation of this file.
1// checking for std::uncaught_exception()
2
3
25#include "config.h"
26
27
28#ifndef _RWSTD_NO_HONOR_STD
29# ifdef _RWSTD_NO_STD_TERMINATE
30# include "terminate.h"
31# endif // _RWSTD_NO_STD_TERMINATE
32#endif // _RWSTD_NO_HONOR_STD
33
34
35// will fail if namespaces aren't supported
36namespace std {
37
38// looking for a definition in compiler support library
40
41}
42
43// will cause an error if namespace std isn't being honored
45
46bool foo () { return false; }
47
49
50struct S {
51 ~S () {
52 uncaught = (*uncaught_exception)();
53 }
54};
55
56
57int main (int argc, char *argv[])
58{
59 (void)&argv;
60
61 int result = 0;
62
63 if (argc > 1)
64 uncaught_exception = &std::uncaught_exception;
65 else
67
68 if ((*uncaught_exception)())
69 result = result << 1 + 1;
70
71#ifndef _RWSTD_NO_EXCEPTIONS
72
73 try {
74 S s;
75
76 // do not actually invoke uncaught_exception()
77 // unless at least one command-line argument
78 // is specified (done to prevent the compiler
79 // from optimizing the function call away)
80 if (argc > 1)
81 throw 0;
82 }
83 catch (...) {
84 }
85
86#endif // _RWSTD_NO_EXCEPTIONS
87
88 if (uncaught)
89 result = result << 1 + 1;
90
91 return result;
92}
#define s
volatile int result
#define main
bool(* uncaught_exception)()
Definition json.h:5363
#define bool
Definition stdbool.h:24