vishnu.prasad has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: [OT] Macro Problem
by Corion (Patriarch) on Dec 29, 2010 at 13:38 UTC

    Maybe use Perl to expand your source code instead of C macros? I'm sure it wouldn't be too hard to search and replace the expression.

    Most likely you want to look at Text::Balanced to parse the bracketed expressions. The rest should be some basic string manipulation.

    If you have concrete problems with your Perl code, please post it and some small but relevant input and output data, and how it fails for you.

Re: [OT] Macro Problem
by Anonyrnous Monk (Hermit) on Dec 29, 2010 at 14:01 UTC
    i want to define a macro where i can print a variable's name and value
    #define DBG(x) printf("DEBUG >> "#x" == %d\n",(x))

    See Quoting macro arguments

    Example:

    #include <stdio.h> #define DBG(x) printf("DEBUG >> "#x" == %d\n",(x)) int main() { int u4_heap_mem_size = 8890; DBG(u4_heap_mem_size+1); // prints DEBUG >> u4_heap_mem_size+1 + == 8891 return 0; }
Re: [OT] Macro Problem
by jethro (Monsignor) on Dec 29, 2010 at 13:38 UTC

    Removed because not really answering the question