Hi All,
        The example from Robert is quite good indeed. Learnt quite
        a bit about macros.

        I used the ideas from it and made a quick&dirty solution
        only to come up with a bug in the Sun CC compiler handling of
        macros with __VA_ARGS__ and the operator "->". (It drops the
        ">" when the macro is expanded.) No such        problems with gcc.

        Thanks a lot to everyone.

Regards,
Rajnish

ps: For those interested, can try it out on the following code(tte):
/*
 * use either: gcc -E <filename>
 *         or: CC -E <filename>
 * to see the difference.
 */
#include <stdio.h>

#define myprintf(str,...) printf(str,__VA_ARGS__);

struct foo {
    int bar;
};

int main() {
    
    foo* a = new foo;
    foo->bar = 10;
    myprintf("foo->bar=%d\n", foo->bar);
    
    return 0;
}
 

::>-----Original Message-----

::>#define debugs(SECTION, LEVEL, CONTENT) \
::>   do { \
::>        if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
::>                Debug::getDebugOut() << CONTENT; \
::>                Debug::finishDebug(); \
::>        } \
::>   } while (/*CONSTCOND*/ 0)
::>  
::>
::>
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to