K
K
kacejot2017-09-04 15:37:44
C++ / C#
kacejot, 2017-09-04 15:37:44

Is there any way to test for going out of scope in C?

Actually, my question is pretty exhaustive. Should be used for advanced logging of entering and exiting functions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2017-09-04
@kacejot

If you are not afraid of GCC extensions, then here: https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Varia...

cleanup (cleanup_function)
The cleanup attribute runs a function when the variable goes out of scope. This attribute can only be applied to auto function scope variables; it may not be applied to parameters or variables with static storage duration. The function must take one parameter, a pointer to a type compatible with the variable. The return value of the function (if any) is ignored.

More: https://en.wikipedia.org/wiki/Resource_acquisition...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question