Location:
e32std.h
Link against:
TRAP(_r,_s) {TTrap __t;if (__t.Trap(_r)==0){_s;TTrap::UnTrap();}}
Supported from 5.0
Executes the set of C++ statements _s
under a trap
harness — use this macro as a C++ statement.
_r
must be a TInt
which has already been
declared; if any of the C++ statements _s
leaves, then the leave
code is returned in _r
, otherwise _r
is set to
KErrNone
.
_s
can consist of multiple C++ statements; in theory,
_s
can consist of any legal C++ code but in practice, such
statements consist of simple function calls, e.g. Foo()
or an
assignment of some value to the result of a function call, e.g.
functionValue=GetFoo()
.
A cleanup stack is constructed for the set of C++ statements
_s
. If any function in _s
leaves, objects pushed to
the cleanup stack are cleaned-up. In addition, if any of the C++ statements in
_s
leaves, then remaining C++ code in _s
is not
executed and any variables which are assigned within that remaining code are
not defined.
Note:
For notes on using TRAP
with functions that do and
do not return a value, and on efficiency.
|