0

I am using VS2010 C++.

For debugging reasons I have commented out lines like this:

ms+=t.getElapsedTimeInMicroSec();

became

//timer:ms+=t.getElapsedTimeInMicroSec();

Now when I want to include all timer lines, I do a simply text replace and replace all "//timer:" with an empty string, and all these lines become active again. But there is no way to include the "//timer:" on all lines again.

I could use

#ifdef _MYVAR
         ms+=t.getElapsedTimeInMicroSec();
#endif

instead, but that would make my code much less readable.

Is there a simply solution for my problem, for example a switch that I put in front of each line to activate or deactive the lines?

4

2 回答 2

4
/*timer*/ // ms+=t.getElapsedTimeInMicroSec();

Now you can search and replace "/*timer*/ //" with "/*timer*/". Then later, search and replace "/*timer*/" with "/*timer*/ //".

于 2013-09-22T17:09:00.933 回答
0

You can use regex search (Regular Expressions), if you want the code to be more readable.

you can use a line like this

ms+=t.getElapsedTimeInMicroSec(); //TIMER

and search for (.*) \/\/TIMER and replace with //($1) //TIMER

and for removal search for //(.*) \/\/TIMER and replace with ($1) //TIMER

于 2013-09-22T17:14:09.043 回答