prassi has asked for the wisdom of the Perl Monks concerning the following question:
Here is the problem description, I have a .h file which has all the "macro" flags definition and the .c file uses these macro.
The problem is I need to remove the part of the code which are undefined in the .c file. Here is the example,
Below is the example of "types.h" file,
#include <stdio.h> #include <stdlib.h> #define ALPHA 1 #define BETA #define GAMMA 0
Here is the corresponding C file
The above example is a dummy example from the above code the result has to be like,#include "types.h" void main() { int a, b, c; float d,e,f; #if (ALPHA) c = a+b; #endif #ifdef BETA f = e*d; #if (GAMMA) c = c + 10; #endif #endif }
void main() { int a, b, c; float d,e,f; #if (ALPHA) c = a+b; #endif #ifdef BETA f = e*d; #endif }
I was reading through the XS of perl will this help me, as of now I dont have any code or solution still looking for ideas.
Thanks a lot, -Prassi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: C macro pre processing
by CountZero (Bishop) on Jun 24, 2012 at 08:19 UTC | |
|
Re: C macro pre processing
by BrowserUk (Patriarch) on Jun 24, 2012 at 06:53 UTC | |
by Corion (Patriarch) on Jun 24, 2012 at 07:45 UTC | |
by BrowserUk (Patriarch) on Jun 24, 2012 at 07:56 UTC | |
by afoken (Chancellor) on Jun 24, 2012 at 07:59 UTC | |
|
Re: C macro pre processing
by roboticus (Chancellor) on Jun 24, 2012 at 15:03 UTC | |
|
Re: C macro pre processing
by bulk88 (Priest) on Jun 24, 2012 at 14:25 UTC | |
|
Re: C macro pre processing
by Anonymous Monk on Jun 24, 2012 at 06:06 UTC |