Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
EXTERN_C_EXCEPTIONS.cpp
Go to the documentation of this file.
1
// checking for exceptions from extern "C" functions
2
3
25
// test tries to determine whether it's possible to throw exceptions
26
// from functions with C language linkage
27
28
extern
"C"
{
29
30
int
extern_c_function
(
int
x
,
int
y
,
int
(*
fun
)(
int
,
int
))
31
{
32
if
(
fun
)
33
return
fun
(
x
,
y
);
34
35
return
0;
36
37
}
38
39
int
div_throw
(
int
x
,
int
y
)
40
{
41
if
(0 ==
y
)
42
throw
y
;
43
44
return
x
/
y
;
45
}
46
47
int
div_nothrow
(
int
x
,
int
y
)
48
{
49
if
(0 ==
y
)
50
return
0;
51
52
return
x
/
y
;
53
54
}
55
56
typedef
int
cfun_t
(
int
,
int
);
57
58
59
}
// extern "C"
60
61
62
int
main
(
int
argc,
char
*argv[])
63
{
64
const
int
x
= argc < 2 ? 0 : int (*argv [1]);
65
const
int
y
= argc < 3 ? 0 : int (*argv [2]);
66
67
cfun_t
* pcfun = argc < 4 ?
div_throw
:
div_nothrow
;
68
69
int
result
;
70
71
try
{
72
result
=
extern_c_function
(
x
,
y
, pcfun);
73
}
74
catch
(
int
res
) {
75
result
=
res
;
76
}
77
78
return
result
;
79
}
y
#define y
Definition
17.names.cpp:141
fun
#define fun
Definition
17.names.cpp:471
res
#define res
Definition
17.names.cpp:531
x
#define x
Definition
17.names.cpp:140
result
volatile int result
Definition
18.limits.traps.stdcxx-624.cpp:35
main
#define main
Definition
BAD_ALLOC_COPY_CTOR.cpp:32
div_throw
int div_throw(int x, int y)
Definition
EXTERN_C_EXCEPTIONS.cpp:39
cfun_t
int cfun_t(int, int)
Definition
EXTERN_C_EXCEPTIONS.cpp:56
extern_c_function
int extern_c_function(int x, int y, int(*fun)(int, int))
Definition
EXTERN_C_EXCEPTIONS.cpp:30
div_nothrow
int div_nothrow(int x, int y)
Definition
EXTERN_C_EXCEPTIONS.cpp:47
Generated by
1.9.8