Re: Multiple c files

From: jacob navia (jacob_at_jacob.remcomp.fr)
Date: 07/08/04


Date: Thu, 8 Jul 2004 01:55:32 +0200


"vishal" <vishalb@gmail.com> a écrit dans le message de
news:2a254f80.0407071216.4bff7ee1@posting.google.com...
> Is it possible using any tool to get a single C file containing a
> combined code of multiple C files. The single file should include the
> contents of the header file.
>
> Example if I have following files:
> first.c
> second.c
> second.h(included in first.c)
>
> I want a tool that would combine all the contents of these files in
> one file
>
> combined.c
>
> Now if I compile combined.c I should get same result as original
>
> Hope I am clear.
> Thanks in advance

Merging two modules is a delicate operation. The crux of the matter is to
see
if there isn't any name-clashes, meaning if common names are used in the
same way.

1: static functions in the two modules could have the same name.
2: Macros could have the same name but different value/expansion.
3: One file could have a set of
#ifndef SOMESYMBOL
#endif
   based in some symbol *not* being defined. If the other module defines
that
   symbol, code could get included that it shouldn't.

Most of the time the merger is just adding the two source files, but watch
for the above problems. A simple way to check for those is to add
file a.c THEN file b.c. Compile, save the object file. Then, put first b.c
and THEN a.c. Compile and compare the object files.
They should be the same.



Relevant Pages

  • Multiple c files
    ... combined code of multiple C files. ... The single file should include the ... Now if I compile combined.c I should get same result as original ...
    (comp.lang.c)
  • Re: Dependency analysis
    ... >I needed some help in figuring out how to approach the following ... > then import all its dependencies and check for their dependencies and ... jars them into a single file? ... compile that one class you use. ...
    (comp.lang.java.programmer)
  • Re: Use of libraries
    ... when I'm developing them I only have to compile a single file (the ... Yes, I have a makefile, but I can compile and rerun the test before ...
    (comp.lang.vhdl)
  • Re: Why doesnt C# allow incremental compilation like Java?
    ... after every single change I make to a single file. ... files to get a unit of work done, and compile that. ... the GUI, test, and make changes, and test without having to relaunch ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Multiple c files
    ... > combined code of multiple C files. ... The single file should include the ... > contents of the header file. ...
    (comp.lang.c)