Sign in to follow this  

C++ Trick I can't remember...

This topic is 3341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know that C++ trick that allowed us to code a function that would be called each time we called a function? Let me explain, in a normal program, Function A calls Function B. Using this system, A would call our pre-defined code, and then B. From what I remember some people used it as a tracer... Any ideas?

Share this post


Link to post
Share on other sites
Quote:
Original post by Prozak
Does anyone know that C++ trick that allowed us to code a function that would be called each time we called a function?

Let me explain, in a normal program, Function A calls Function B. Using this system, A would call our pre-defined code, and then B.

From what I remember some people used it as a tracer...

Any ideas?
It doesn't work exactly like you specify, but in MSVC there is _penter and _pexit which are inserted in the beginning and end of each function, such that the sequence would be
Function A's Code -> Function B -> _penter -> Function B's Code -> _pexit -> Back to Function A's Code

The distinction from what you said is that the calls to _penter and _pexit are inserted inside function B, so if function B is inside a library that was compiled with different settings, _penter and _pexit will not be called.

Share this post


Link to post
Share on other sites

This topic is 3341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this