Differences
This shows you the differences between two versions of the page.
— |
ile_c_exception_handling [2021/04/05 11:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== ILE C Exception Handling ====== | ||
+ | Normally C knows nothing of exceptions and thus has no exception handling. It communicates via return codes and signals. | ||
+ | |||
+ | On IBM i there is the concept of messages and escape messages are exceptions which abort the execute of code. | ||
+ | |||
+ | In ILE C there is the option of using ''# | ||
+ | |||
+ | <sxh c> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | void handleError(_INTRPT_Hndlr_Parms_T * __ptr128 parms); | ||
+ | |||
+ | int main(void) { | ||
+ | |||
+ | volatile int value = 12; | ||
+ | int divisor = 0; | ||
+ | int result; | ||
+ | |||
+ | #pragma exception_handler(handleError, | ||
+ | result = value / divisor; | ||
+ | #pragma disable_handler | ||
+ | |||
+ | printf(" | ||
+ | |||
+ | return 0; | ||
+ | |||
+ | } | ||
+ | |||
+ | void handleError(_INTRPT_Hndlr_Parms_T * __ptr128 parms) { | ||
+ | int * commAreaValue = parms-> | ||
+ | printf(" | ||
+ | printf(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | {{tag> |