Re: combining c-code files into one c-code file

Gene <gene.ressler@gmail.com>
Mon, 9 Apr 2012 05:40:48 -0700 (PDT)

          From comp.compilers

Related articles
combining c-code files into one c-code file harald.gustafsson@gmail.com (Harald Gustafsson) (2012-04-03)
Re: combining c-code files into one c-code file cameron.mcinally@nyu.edu (Cameron McInally) (2012-04-04)
Re: combining c-code files into one c-code file harald.gustafsson@gmail.com (Harald Gustafsson) (2012-04-04)
Re: combining c-code files into one c-code file gene.ressler@gmail.com (Gene) (2012-04-09)
Re: combining c-code files into one c-code file harald.gustafsson@gmail.com (Harald Gustafsson) (2012-04-18)
| List of all articles for this month |

From: Gene <gene.ressler@gmail.com>
Newsgroups: comp.compilers
Date: Mon, 9 Apr 2012 05:40:48 -0700 (PDT)
Organization: Compilers Central
References: 12-04-005
Keywords: code, C
Posted-Date: 09 Apr 2012 13:05:27 EDT

On Apr 3, 9:23 am, Harald Gustafsson <harald.gustafs...@gmail.com>
wrote:
> I'm asking if anyone knows of a tool that can take a list of c-files and
> pre-process/merge that into one c-file, managing redeclarations, conflicting
> declarations, declaration order, etc. The readability of the output is less
> important but prefers as human readable as possible.


I don't know a tool, but I've done this (for a completely different
reason) with a moderately complex program. Conflicting preprocessor
definitions were the main problem as for you. We ended up writing a
script to have gcc dump preprocessor definitions (there is a command
line flag for this), converting them to "undefs". This was run on
each source file to effectively create a cpp table cleanup that we
could include after each source file. So the master file looked like


#include "foo.c"
#include "foo.undefs.c"
#include "hoo.c"
#include "hoo.undefs.c"
...


This isn't sufficient for all programs (e.g. the weak symbol case
already mentioned). E.g. there ware cases where static declarations
conflicted and it was necessary to modify the static name locally with
#define #undef .


...
#define conflicting_static_name BAR_conflicting_static_name
#include "bar.c"
#include "bar.undefs.c"
#undef conflicting_static_name
...



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.