Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does abort() and terminate() "live"?

Tags:

c++

Regarding the terminate handler,

As i understand it, when something bad happens in code, for example when we dont catch an exception,

terminate() is called, which in turn calls abort()

set_terminate(my_function) allows us to get terminate() to call a user specified function my_terminate.

my question is: where do these functions "live" they don't seem to be a part of the language, but work as if they are present in every single cpp file, without having to include any header file.

like image 361
aCuria Avatar asked Apr 24 '10 17:04

aCuria


1 Answers

If there are default handler functions for terminate and abort that you did not install yourself, they'd have to be in the runtime library provided by your compiler.

Normally, every program is linked against the runtime library (e.g. glibc under Linux). Among other reasons, this is because the runtime library contains "hidden" code for essential things, e.g. code that calls your main function at startup.

like image 60
stakx - no longer contributing Avatar answered Sep 28 '22 15:09

stakx - no longer contributing