On Sat, 07 Jun 2008 02:33:28 -0700, Raman wrote:
Quote:
Hi All,
>
We have an old code base which (unfortunatelty) has some C files that
include other C files:e.g
>
File.c
=====
#include<stdio.h>
.
void someFunc(){
.
.
}
>
#include<culprit.c>
>
void someOtherFunc(){
>
callAFunctionDefinedinCluprit()
>
}
=====
>
>
Here, File.c includesa C file called culprit.c.
>
Problem:
We are porting this code base to Mainframes. The debugger there (
iSeries system debugger) does not support inclusion of the files. When
control of the execution reaches in culprit.c, debugger is unable to
highlight the statement being executed currently.
>
Possible Solution;
We could copy-paste the culprit.c in the File.c, However there are some
other files like Second.c that also include culprit.c. So the code of
culprit will be redundant.
>
Here's a cut-and-paste equivalent that avoids manual
duplication of code. Generate the ".c" sources from
a template using cpp:
1. mv File.c File.tpl
2. Edit File.tpl to add "#ifdef TEMPLATE" around all ".h" includes.
3. Provide for the generation of the source ".c" files in the makefile:
cpp -P -D TEMPLATE File1.tp File.c
Add rules to the makefile to handle .tpl -.c
CPP=gcc -E -P # or /lib/cpp -P, /usr/bin/cpp -P etc.
.SUFFIXES: .tpl
.tpl.c:
$(CPP) -P -DTEMPLATE $^ $@
File.tpl
=====
#ifndef TEMPLATE
#include<stdio.h>
/* Any other includes */
#else
/* This File generated by cpp from File.tpl do not edit. */
#endif
void someFunc(){
..
..
}
#include<culprit.c>
void someOtherFunc(){
callAFunctionDefinedinCluprit()
}
=====
Quote:
>
Please help, if any other solution exists.
>
Hope that helps. Your cpp may be different.
-Louis
Quote:
I understand this group is not about debugger/ Mainframes, However I
posted this query in this group because after all this is a bad
programming design as per the C language.
>
Also, If any one can suggest some place/group that discuss Mainframes.
>
Thanks and Regards,
Raman Chalotra