This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug pch/13675] #including a precompiled header more than once in the same unit fails
- From: "pegasus at ifdo dot pugmarks dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jun 2004 03:55:45 -0000
- Subject: [Bug pch/13675] #including a precompiled header more than once in the same unit fails
- References: <20040114031017.13675.jbrandmeyer@earthlink.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pegasus at ifdo dot pugmarks dot com 2004-06-03 03:55 -------
Simpler test case:
touch a.h
echo '#include "a.h"' > a.c
echo '#include "a.h"' >> a.c
gcc a.h -o a.h.gch
gcc -c a.c -o a.o
The last gcc execution gives:
a.c:2:15: calling fdopen: Bad file descriptor
Possible workaround:
Disclamer: This is the first time I look at gcc's source code. This patch is
UNtested. Don't blame me if anything bad happens, etc..
This "works" by telling gcc to load the file once only. If loading the file more
than once was intentional, this will break your compilation.
--- gcc-3.4.0/gcc/cppfiles.c 2004-02-07 09:33:08.000000000 -0500
+++ gcc-3.4.0-new/gcc/cppfiles.c 2004-06-02 22:55:50.316126744 -0400
@@ -577,6 +577,7 @@
pfile->cb.read_pch (pfile, file->path, file->fd, file->pchname);
close (file->fd);
file->fd = -1;
+ _cpp_mark_file_once_only (pfile, file);
return false;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13675