While attempting to compile Xerces 2.7 on MacOS, I discovered what I think is a bug in gcc, which I'm using for all phases of build. The c++ preprocessor is emitting line number statements which have an inconsistent number of arguments after the file name, e.g.: # 1 "/usr/include/xercesc/util/XMLEnumerator.hpp" 1 3 4 vs. # 25 "/usr/include/xercesc/util/XMLEnumerator.hpp" 3 4 and, in the former case (with the extra number), it seems to introduce some compiler behavior where a subsequent template class definition will be rejected with the misguiding error message "template with C linkage". I have whittled the problem down to a single preprocessed source file that exhibits this problem - will try to attach it once I can figure out Bugzilla's UI. Thanks for your help and advice! Alan
Created attachment 13892 [details] simple C++ input file that shows the problem
Created attachment 13893 [details] minor tweaking of c++ preprocessor output which fixes the problem
zeus:~/projects/xerces-c-src_2_7_0 pitaman$ gcc fails.cpp /usr/include/xercesc/util/XMLEnumerator.hpp:2: error: template with C linkage zeus:~/projects/xerces-c-src_2_7_0 pitaman$ gcc succeeds.cpp /usr/bin/ld: Undefined symbols: _main collect2: ld returned 1 exit status
How did /usr/include/xercesc come to exist? Was it there before compiling Xerces or did it use that as the default path for install?
Subject: Re: bogus "template with C linkage" from erroneous #line directives That directory did not exist - once I had built Xerces I manually copied the files there. Alan On Jul 11, 2007, at 8:25 PM, pinskia at gcc dot gnu dot org wrote: > > > ------- Comment #4 from pinskia at gcc dot gnu dot org 2007-07-12 > 01:25 ------- > How did /usr/include/xercesc come to exist? Was it there before > compiling > Xerces or did it use that as the default path for install? > > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32734 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter.
Don't copy into /usr/include, use /usr/local/include instead. Anyways the underlaying issue has been fixed for 4.2.0.
Subject: Re: bogus "template with C linkage" from erroneous #line directives Good to know it. Thanks for the response. Alan On Jul 12, 2007, at 4:20 PM, pinskia at gcc dot gnu dot org wrote: > > > ------- Comment #6 from pinskia at gcc dot gnu dot org 2007-07-12 > 21:20 ------- > Don't copy into /usr/include, use /usr/local/include instead. > > Anyways the underlaying issue has been fixed for 4.2.0. > > > -- > > pinskia at gcc dot gnu dot org changed: > > What |Removed |Added > ---------------------------------------------------------------------- > ------ > Status|UNCONFIRMED |RESOLVED > Resolution| |WORKSFORME > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32734 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter.
This is clearly not fixed, even in 4.2.2. In file included from fails.cpp:2: /usr/include/xercesc/util/XMLEnumerator.hpp:2: error: template with C linkage