On 02/06/2009, at 12:12, Martin Costabel wrote:
> The most difficult thing was to find out how to print the value of a
> macro at a given moment. From a diving expedition into the depths of  
> the
> docs, I brought home some macros that give the following small example
> program in C:
>
> #include <stdio.h>
> // stringify the value of a macro for printing
> #define str(x) #x
> #define xstr(x) str(x)
> // play with replacing macros
> #define OLD_DEBUG 1
> #define DEBUG OLD_DEBUG
> int main(){
>         printf("Before: %s\n", xstr(DEBUG));
> #undef OLD_DEBUG
>         printf("After : %s\n", xstr(DEBUG));
>         return(0);
> }
>
> If you compile and run this, it prints
>
> costabel% ./a.out
> Before: 1
> After : OLD_DEBUG
>
> I don't know enough to say that there are no analogues of \edef or  
> \let,
> but I haven't come across them yet.


Martin,

You may use GCC flags -E and -dD to achieve that in compile-time  
rather than run-time. For example,

gcc -E -dD program.c -o program.e

outputs program.e, the post-processed version of program.c. -E tells  
gcc to preprocess the file but not compile/build it, and -dD tells gcc  
to output the values of macros.


Cheers,

--
monipol


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Fink-devel mailing list
Fink-devel@lists.sourceforge.net
http://news.gmane.org/gmane.os.apple.fink.devel

Reply via email to