Message-Id: <3.0.16.19971017112420.2b47a9b4@hem1.passagen.se> Date: Fri, 17 Oct 1997 11:24:23 -0400 To: darn AT merlin DOT imag DOT net From: Peter Palotas Subject: Re: CPP question. Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk At 22.27 1997-10-16 -0700, you wrote: >Peter Palotas wrote: >> >> Is there some way to make CPP (the macro preprocessor) not include files >> from included files? i.e. if there's a line #include "file1.h" in the file > > >Oh my. That's a bit hard to decypher. Do you mean something like this: Okay... Let's get this straight then... If I have a file: -------------- file.c ----------------- #ifndef __MY_HEADER__ #define __MY_HEADER__ #include #include #ifdef _INCLUDE_MY_DOS_H_ #include "mydos.h" #endif #include "file.h" int main(void) { return 0; }; -------------- mydos.h ---------------- #include #include "file2.h" void my_func(void); -------------- file.h ----------------- #include int my_func_again(void); int this_was_no_fun_writing(void); ------------- file2.h ----------------- /* This is file2.h I'm really too lazy */ /* to write any code here, so this will */ /* have to be sufficient! */ Okay... Now what I would prefer the output to be (if _INCLUDE_MYDOS_H_ was defined) would be the following: ------------- desired output ---------- #ifndef __MY_HEADER__ #define __MY_HEADER__ #include #include #ifdef _INCLUDE_MY_DOS_H_ #include /* This is file2.h I'm really too lazy */ /* to write any code here, so this will */ /* have to be sufficient! */ void my_func(void); #endif #include int my_func_again(void); int this_was_no_fun_writing(void); int main(void) { return 0; }; And I actually managed to solve this problem too, in a somewhat ugly way maybe, by writing an AWK program (actually two of them) that took care of the includes (it is called recursively, so I guess it uses a lot of memory), and then calling CPP which would only do what I wanted it to do since all the other #defines and stuff were commented out by the first AWK program, and the second AWK program would only uncomment all these #preprocessor-statements. -- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se -- ***************************************************** * A brief description of DJGPP: * * NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! * *****************************************************