C provides the following built-in tools for debugging:
-
__FILE__
,__LINE__
and__func__
can be used within a function to describe itself during execution, and help trace where a problem begins. They are most useful in macros, where they won't be resolved until the macro is expanded. -
assert
can be used to make certain that beliefs about the state of an executing program at a specific moment are correct.static_
can be used to abort translation if essential guarantees about the environment cannot be met.assert -
Many interactions with the run-time environment may fail due to misuse by the program, or because of external factors beyond the program's control. The type of failure is often reported through
errno
.