[Bug pch/13675] #including a precompiled header more than once in the same unit fails
pegasus at ifdo dot pugmarks dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 3 03:55:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list