From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12386 invoked by alias); 3 Jun 2004 03:55:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12367 invoked by uid 48); 3 Jun 2004 03:55:45 -0000 Date: Thu, 03 Jun 2004 03:55:00 -0000 Message-ID: <20040603035545.12366.qmail@sourceware.org> From: "pegasus at ifdo dot pugmarks dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040114031017.13675.jbrandmeyer@earthlink.net> References: <20040114031017.13675.jbrandmeyer@earthlink.net> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug pch/13675] #including a precompiled header more than once in the same unit fails X-Bugzilla-Reason: CC X-SW-Source: 2004-06/txt/msg00306.txt.bz2 List-Id: ------- 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