Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #552

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!nerds-end
From Gene <gene.ressler@gmail.com>
Newsgroups comp.compilers
Subject Re: combining c-code files into one c-code file
Date Mon, 9 Apr 2012 05:40:48 -0700 (PDT)
Organization Compilers Central
Lines 33
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <12-04-009@comp.compilers> (permalink)
References <12-04-005@comp.compilers>
NNTP-Posting-Host news.iecc.com
X-Trace leila.iecc.com 1333991127 80056 64.57.183.58 (9 Apr 2012 17:05:27 GMT)
X-Complaints-To abuse@iecc.com
NNTP-Posting-Date Mon, 9 Apr 2012 17:05:27 +0000 (UTC)
Keywords code, C
Posted-Date 09 Apr 2012 13:05:27 EDT
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
X-Received-Bytes 2305
Xref csiph.com comp.compilers:552

Show key headers only | View raw


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
...

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

combining c-code files into one c-code file Harald Gustafsson <harald.gustafsson@gmail.com> - 2012-04-03 06:23 -0700
  Re: combining c-code files into one c-code file Cameron McInally <cameron.mcinally@nyu.edu> - 2012-04-04 12:02 -0400
  Re: combining c-code files into one c-code file Harald Gustafsson <harald.gustafsson@gmail.com> - 2012-04-04 19:35 +0200
  Re: combining c-code files into one c-code file Gene <gene.ressler@gmail.com> - 2012-04-09 05:40 -0700
  Re: combining c-code files into one c-code file Harald Gustafsson <harald.gustafsson@gmail.com> - 2012-04-18 02:01 -0700

csiph-web