Mix different C source files into a single one

Michael L Torrie torriem at chem.byu.edu
Sat Dec 29 14:41:25 EST 2007


Horacius ReX wrote:
> Hi,
> 
> I have a C program split into different source files. I am trying a
> new compiler and for some reason it only accepts a single source file.
> So I need to "mix" all my different C source files into a single one.
> 
> Do you know about some type of python script able to do this kind of
> task ?

No, but bash and friends can:

cat *.c > newfile.c

If you're stuck working with windows, the copy command can also
concatenate files.

After concatenating the files, editing the file to remove/merge #include
directives would work.  Any compiler that can only deal with a single
source file is of course extremely limited in what it can do, so this
manual process shouldn't be too bad for short programs (all that this
compiler can really deal with).

> 
> Thanks




More information about the Python-list mailing list