mercredi 4 juillet 2018

Add a macro in the beginning and end of each function

I am working on a huge project in Visual Studio 2013 C++ and I want to be able to print entry and exit logs for each function/method. I looked up many ways, many of which are given as an answer to this question,

Automatically adding Enter/Exit Function Logs to a Project

and looked up similar questions in stack overflow and elsewhere but came to the conclusion that _penter and _pexit is not going to work for me for two reasons - the application is an x64 application and also to get the name of the function is not trivial and is expensive.

I decided to go the good old way of adding macro at every function and get the function name printed in the macro. Now, I am stuck since I am not able to trivially add a macro to the entry and exit of every function.

Can somebody help me with a script(bash script is fine since I can using it using cygwin) maybe using sed or something similar to do the job of introducing the macro at the entry and exit.

We have functions like -

" Name(...) {"

" Name(...)

{"

I want to be able to add it to only to the functions and not to every block(if/while/etc).

TIA!

Aucun commentaire:

Enregistrer un commentaire