Daniele Cruciani
Programmatore Developer PHP/MySQL Freelance
mobile: +39 3489215204

icq skype msn linkedin fb t ff youtube picasa google
seconds to the end of World
End of World 21 December, 2012 11:11:00
Hire me before that day! | don't bother

setjmp

C Language Exception Handling

Error handling

It is common for a program to manage non standard situation, like things does not work as expected, or time is expired on operation, or everything else.

Typically C (as any old language) do manage such situation with error code returned, possible errno setted and a table of string that explain errno (sys_errlist). Thus a typical error management in C require to test any error on functions that may returns error (almost all standard libc functions) and, if error occur, manage it some way. Contrarily in C++ (and all new object oriented language) there is the exception idiom. This require runtime support that have a cost, and that make, for example, Symbian OS (aka EPOC32) developer decide to drop this support in the name of performance and memory allocation fault tolerance (see TRAPD/Leave mechanism).

Object oriented idiom is not strictly related to object oriented language, generally it is a way to structure your code using the concepts of object model (encapsulation, inheritance, polymorphism). A good example of object oriented library wroten in plain C language is the GIMP Tool Kit. I tend to consider exception handling a part of object idiom, and this part is what is missing in most object oriented libraries.

Syndicate content