help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using m4 for extracting C source


From: Devesh Sharma
Subject: Using m4 for extracting C source
Date: Thu, 13 Oct 2005 19:58:38 +0530

Hi all,

I am trying to extract some part of C source code defined under
certain Macro statements
for example this is a code

#include<stdio.h>
#include<unistd.h>

int main(void)
{

int my_int = 10 ;

#ifdef TEST_MACRO
int his_int = 20 ;
#else
int other_int = 40;
#endif

printf( "Test Program\n");

#ifdef TEST_MACRO
printf("his_int=%d\n",his_int);
#else
printf("other_int=%d\n",other_int) ;
#endif

printf("my_int=%d\n",my_int);

return 0 ;

}

Now after some processing using m4 I want following type of output

#include<stdio.h>
#include<unistd.h>
int main(void)
{

int my_int = 10 ;


int his_int = 20 ;




printf( "Test Program\n");


printf("his_int=%d\n",his_int);




printf("my_int=%d\n",my_int);

return 0 ;

}

using gcc -E is ofcourse one way of doing this but Is it possible using m4?
Is it possible?
Please any body tell me !!!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]