Mix different C source files into a single one
Benjamin
musiccomposition at gmail.com
Sat Dec 29 16:47:30 EST 2007
On Dec 29, 12:05 pm, Horacius ReX <horacius.... at gmail.com> 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.
That sounds like one crumy compiler.
>
> Do you know about some type of python script able to do this kind of
> task ?
No, but we can write one:
import sys
if __name__ == "__main__":
glob = ""
for file in sys.argv[1:-1]:
glob += "\n" + open(file, "r").read()
open(sys.argv[-1], "w").write(glob)
It's stupid, but it'll work for basic tasks. (I would actually just
use cat; that's what it's for. :))
>
> Thanks
More information about the Python-list
mailing list