This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
cpp seems not to include # line "file" output for empty files
- To: gcc-bugs at gcc dot gnu dot org
- Subject: cpp seems not to include # line "file" output for empty files
- From: "E. Jay Berkenbilt" <ejb at ql dot org>
- Date: Sun, 8 Oct 2000 15:26:05 -0400
With gcc 2.96-20000731 as included with vanilla RedHat Linux 7.0
(i386) cpp does not provide # line ... output for include files that
don't generate any output. This is very bad for automatic dependency
generators. Create the following two files:
a.h:
#define HELLO 1
a.c:
#include "a.h"
Then run cpp a.c
With an older version you get
# 1 "a.c"
# 1 "a.h" 1
# 1 "a.c" 2
With 2.96, you get
# 1 "a.c"
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. Such functionality
is essential for writing portable dependency generators. 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.