On Wed, 2003-10-22 at 18:39, Tiwari, Rajnish wrote:
> Hi All,
> 
>       I am stuck trying to decide on 2 courses of action - one
>       of which involves changes to loads of files (I wish to avoid
>       doing this if possible).
> 
>       Currently, I have this C-function:
>       int DEBUG(char* xstr, int somelevel)
>        { 
>          // pseudo-pseudo-code follows
>          if ( somelevel < 10 )
>               print xstr;
> 
>          return 0;
>        }
> 
>        char* fs(const char* fmt, ...);
> 
>        And they are used as follows (as an example):
>       DEBUG( fs("%s%s", "-----", "====="), 25 );
> 
> 
>       I aim to deprecate the use of fs() - as you will see the call to
>       fs() is wasted its output isn't being printed. I aim to shove down
>       that responsibility to DEBUG itself.
> 
>        My Question:
>        Is it possible to do use C-processor macros to define fs() to
>        _become_ nothing, and call my new DEBUG with the follow prototype:
>        int NEW_DEBUG(int somelevel, const char* fmt, ...);    ??
> 
>       That is:
>        #define fs(msg,...) ??????     // leaves me with just "msg,..."
>       #define DEBUG(const char*, ... , level) NEW_DEBUG(level, const
> char*, ????)
> 
>       (Please note: I have used incorrect CPP syntax as I am trying
>         to get an idea across only [and also 'cos I don't know howto])
> 
>       Is the above idea possible - or I should go ahead and do the
> hundreds
>       of lines of changes ?

You are trying to hard.  Ignore fs and what it does and have another
look at DEBUG:

        int DEBUG(char* xstr, int somelevel)

If you translate this into nothing then you wont even have the function
call left.  The catch to this sort of change is programming by side
effect.

DEBUG( "something", i++ );

If you translate this to nothing then i++ just goes away as well.  If
nothing strange is in your code then a simple macro will do the trick.

#define DEBUG(x,y)

You will get another error, I will leave this for you to ponder where
:-)

-- 
Thanks
KenF
OpenOffice.org developer

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to