Re: Preprocessing with gcc -E



Tim Frink <plfriko@xxxxxxxx> writes:

First of all, sorry for the double post.

I am tempted to say, stop wanting that. Even in you get something
that works, it will interact badly with build tools like make that can
compile source files in any order. What is the coding problem that
you are trying to solve this way?

I'll answer here to all the other posts: I have a prototype program
analysis tool that only accepts single files. The benchmark I wanted
to evaluate however consists of multiple compilation units. So my
idea was to "paste" all files automatically into one file via a
preprocessor. But this doesn't seem to work.

No, it won't work. In C the file boundaries are important. If you
concatenate sources the result not likely to be legal C and crucial
information will have been lost.

However, I'm still somewhat surprised because
"gcc a.c b.c" works fine. If each function is handled separately
I would expect to get some error of type "multiple definition of"
int_least8_t ... Why does this not happen?

Linking two compiled files (C calls the compilation units), each of
which contains a typedef for this type does not result in anything
being multiply defined. Essentially, a typedef is not visible outside
of the unit that contains it. If the same type name was defined twice
in the same compilation unit, or two separate compilation units
defined the same object with external linkage, you would get an error.

--
Ben.
.



Relevant Pages

  • Re: Implementing an Ada compiler and libraries.
    ... manage to find compilation units with'd? ... Keep a data structure that tells which compilation units are in which ... Generate the AST from the parse tree? ...
    (comp.lang.ada)
  • Re: Standard Ada Preprocessor (Was: why ada is so unpopular ?)
    ... > compilation, then I believe, it could be 80% of the issue. ... > If we could limit variations to compilation units, I think we could, ... > then there might be a better way than preprocessing. ... Whether conditional compilation comes about by preprocessing ...
    (comp.lang.ada)
  • Re: Shared Libraries : library paths ??
    ... Compilation units have advantages. ... > It's interesting to note that languages with all these supposedly nice ... fault tree analysis software in written in M2. ...
    (comp.os.linux.development.system)
  • Re: Shared Libraries : library paths ??
    ... Compilation units have advantages. ... > It's interesting to note that languages with all these supposedly nice ... fault tree analysis software in written in M2. ...
    (comp.unix.programmer)
  • Re: Shared Libraries : library paths ??
    ... Compilation units have advantages. ... > It's interesting to note that languages with all these supposedly nice ... fault tree analysis software in written in M2. ...
    (comp.os.linux.development.apps)