If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: a clean macro to make a part of code obsolete

My code is unstable currently and I want just to disable some part of it without removing it
maybe i decide to include that part again
#ifdef is a good solution but I was wondering if there is any other choice

Re: a clean macro to make a part of code obsolete

Why not just comment the code out? If you use the block comment/uncomment command (select a block and Ctrl+K, Ctrl+C / Ctrl+K, Ctrl+U in VC) it's also easier to reactivate the code part by part (no need for adding #ifdef / #endif pairs)

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan

Re: a clean macro to make a part of code obsolete

Originally Posted by S_M_A

Why not just comment the code out? If you use the block comment/uncomment command (select a block and Ctrl+K, Ctrl+C / Ctrl+K, Ctrl+U in VC) it's also easier to reactivate the code part by part (no need for adding #ifdef / #endif pairs)

The problem with that approach is that it doesn't work if there is already a block comment in your code or if you want blocks within blocks.

Code:

void foo()
{
/*
/*
*/ // comment ends here
*/ // compiler error
}

Cheers, D Drmmr

Please put [code][/code] tags around your code to preserve indentation and make it more readable.

As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky