[Bug pch/13675] New: #including a precompiled header more than once in the same unit fails

jbrandmeyer at earthlink dot net gcc-bugzilla@gcc.gnu.org
Wed Jan 14 03:10:00 GMT 2004


This has also been observed on powerpc-apple-darwin6.8 with current sources as
of 1pm US Eastern time today when configured with ../gcc/configure
--enable-languages=c,c++ --program-suffix=-3.4
--enable-version-specific-runtime-libs

Both the C and C++ compilers are affected.

If a header file is precompiled and #included more than once in the same
compilation unit, the second inclusion generates an error like
"filename:linenumber:columnnumber calling fdopen: Bad file descriptor"

Consider this trivial example:
-----------pch-header.h-------
#ifndef PCH_HEADER_TEST_H
#define PCH_HEADER_TEST_H
extern int i;
#endif
----------another-pch-user.h-------
#include "pch-header.h"
----------pch-user1.cpp-------
#include "pch-header.h"
#include "another-pch-user.h"
---------------end----------
$ g++-3.4 -c -o pch-header.h.gch pch-header.h
$ g++-3.4 -c -o pch-user1.o pch-user1.cpp
In file included from pch-user1.cpp:2:
another-pch-user.h:1:24: calling fdopen: Bad file descriptor


$ g++-3.4 -v
Reading specs from /home/jonathan/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc/configure --enable-languages=c,c++ --program-suffix=-3.4
--disable-checking --prefix=/home/jonathan
Thread model: posix
gcc version 3.4.0 20040108 (experimental)

-- 
           Summary: #including a precompiled header more than once in the
                    same unit fails
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: pch
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbrandmeyer at earthlink dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13675



More information about the Gcc-bugs mailing list