This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: cpp seems not to include # line "file" output for empty files
- To: Daniel Berlin <dberlin at redhat dot com>
- Subject: Re: cpp seems not to include # line "file" output for empty files
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Sun, 8 Oct 2000 22:01:08 -0700
- Cc: "E. Jay Berkenbilt" <ejb at ql dot org>, gcc-bugs at gcc dot gnu dot org
- References: <200010081926.e98JQ5609968@soup.ql.org> <m34s2nq6v1.fsf@dan2.cygnus.com>
On Sun, Oct 08, 2000 at 06:57:06PM -0400, Daniel Berlin wrote:
> "E. Jay Berkenbilt" <ejb@ql.org> writes:
>
> >
> > It appears that cpp is deciding that it doesn't have to generate the #
> > line output if there is no output from the file. This makes sense for
> > the intend use of these directives for telling the compiler what
> > filename/line number a line of cpp output came from, but it badly
> > hoses dependency generators and other programs that rely on this
> > output for getting a list of files that cpp read.
The format of cpp's output is not to be depended upon by anyone. It's
a private interface between cpp and cc1. It's not secret, but the
details can change at any time.
> > Such functionality is essential for writing portable dependency
> > generators.
I can think of several better ways to write a portable dependency
generator. First, if the existing -M options don't do what you want,
please tell us what is missing so we can improve them. If you want a
raw dump of each header file entered, use -H. If all else fails, you
can grovel through the code with awk, although I don't recommend it.
> > I feel like I've read this in the ISO standard but I can't seem
> > to find any documentation that firmly states that ISO requires
> > this behavior.
You have not read it in the standard. The standard says nothing
whatsoever about the interface between cpp and cc1. Matter of fact,
it doesn't even treat the preprocessor as a separate function.
Preprocessing is phases 1-4 of translation, which are immediately
followed by phases 5-8. All eight phases can happen in the same
process. Or they can communicate by external files, pipes, smoke
signals, whatever. The standard doesn't care.
> If you want dependency info from cpp, use the switches to tell it to
> give you dependency info.
I generally tend to agree.
> Also, if the file generates no output, then a.c really wasn't dependent
> on it.
Not true - a file consisting entirely of #defines will generate no
output, but most definitely does affect how the rest of the input is
processed.
zw