a clean macro to make a part of code obsolete
Hi
I have a simple macro which I use when I want to disable part of my code
Code:
#define OBSOLETE_CODE(x)
But using this macro when you want to make many lines obsolete in not good
and looks like
OBSOLETE_CODE(
// 100 lines of code
)
I want to have two macro's BEGIN_OBSOLETE and END_OBSOLETE like below
Code:
BEGIN_OBSOLETE
// 100 lines of code
END_OBSOLETE
How should i achieve this as the following commands DO NOT work
Code:
#define BEGIN_OBSOLETE OBSOLETE_CODE(
#define END_OBSOLETE )
Thanks
Re: a clean macro to make a part of code obsolete
Why not just use #if OBSOLETE or #ifdef OBSOLETE? But if the code is really obsolete, why not just remove it?
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)
Re: a clean macro to make a part of code obsolete
Quote:
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
}
Re: a clean macro to make a part of code obsolete
Quote:
Originally Posted by D_Drmmr
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.
The "block comment" S_M_A referred to basically involves prepending // to each of the selected lines.
Re: a clean macro to make a part of code obsolete
Quote:
Originally Posted by
laserlight
Why not just use #if OBSOLETE or #ifdef OBSOLETE? But if the code is really obsolete, why not just remove it?
Or even better, give the macro a meaningful name like OLD_V4_CODE_USING_LISTS