I noticed this problem first with GCC 3.2.3, upgraded to the latest build I could get to compile (3.3), and it still exists. It only seems to appear on Sparc Solaris, I could not reproduce it on any other platform, including Sparc Linux. Essentially, it appears any header file included as "#include <header>" is assumed to be C, even when included in C++ (.cc, .C, .cpp all tested) code. This causes errors if function overloading is used. I reproduced the problem with a very simple test, one header file in /usr/include containing an overloaded function definition, and a C++ main that only includes the header and returns 1. The .ii file looks correct, but on compile it complains that declaration of C function `int test(int, int)' conflicts with `int test(int)'. Your bug reporting guidelines specify to include the preprocessed .ii file, but I don't see any method of attaching a file here. If one would be helpful, please feel free to e-mail me.
System headers really _are_ usually C, not C++. On many systems, they are therefore wrapped into extern "C" { ... } blocks if C++ is used. Can you check whether that is the case on your system as well? Wolfgang
The real system headers mostly are, yes, the ones I'm creating for my own development aren't. And those are the ones with problems. As I mentioned earlier, I reproduced the problem with a very simple set of files. The contents of the two simple files are as below. /usr/include/test.h ------------------------ int test (int a); int test (int a, int b); ------------------------ test.cpp ------------------ #include <test.h> int main(void) { return 1; } ------------------ Also of note, when I put the file in the current directory and include it with '#include "test.h"' it compiles fine.
the config file of solaris does not define NO_IMPLICIT_EXTERN_C which says the header files in the system path is c++ aware. I think this is a feature until Sun (your provider) releases a system with c++ aware headers. I do not know when that is, you have to ask them.
Perhaps I am misunderstanding what you said, but they look fairly C++ aware to me...here's a clip from the top of stdio.h... I'm using Solaris 9, perhaps they implemented that with this version? In which file could I find that value to change? I can test it here. --------------------------------------------------------------------- <snip> /* * Copyright (c) 1993-2001, by Sun Microsystems, Inc. * All rights reserved. */ <snip> /* * Allow global visibility for symbols defined in * C++ "std" namespace in <iso/stdio_iso.h>. */ #if __cplusplus >= 199711L using std::FILE; using std::size_t; using std::fpos_t; <snip> using std::perror; #endif #ifdef __cplusplus extern "C" { #endif <etc, etc...>
Then it looks like this can be fix for 2.9 (aka Solaris 9) only. Then the feature needs to be disabled on Solaris 9.
Subject: Re: GCC 3.3 C++ for Sparc Solaris assumes system header files are C. "numien at deathwyrm dot net" <gcc-bugzilla@gcc.gnu.org> writes: | Perhaps I am misunderstanding what you said, but they look fairly C++ aware to | me...here's a clip from the top of stdio.h... Indeed. | I'm using Solaris 9, perhaps they implemented that with this version? | In which file could I find that value to change? I can test it here. | | --------------------------------------------------------------------- | <snip> | /* | * Copyright (c) 1993-2001, by Sun Microsystems, Inc. | * All rights reserved. | */ | <snip> | /* | * Allow global visibility for symbols defined in | * C++ "std" namespace in <iso/stdio_iso.h>. | */ | #if __cplusplus >= 199711L Aha, I get it. Currently g++ (or libstdc++-v3 I can tell which) defines __cplusplus to 1L because we don't know how to handle Sun's C system headers which are already C++ aware. The point is: In this specific case, it is not that Sun's are not C++ aware, the problem is that they *are*, but we don't know how to build libstdc++-v3 with such systems. Put differently, it is our fault. The fix is not obbious though. There should be an open issue related to __cplusplus somewhere in the archive. -- gaby
Subject: Re: GCC 3.3 C++ for Sparc Solaris assumes system header files are C. "pinskia at physics dot uc dot edu" <gcc-bugzilla@gcc.gnu.org> writes: | Then it looks like this can be fix for 2.9 (aka Solaris 9) only. Then the feature needs to be disabled | on Solaris 9. See past discussion on an issue related to __cplucplus. -- Gaby
Took a bit of time to test and get back here (mostly due to problems with time and Suns, gotta love 'em sometimes) but Andrew Pinski's solution seems to work perfectly. Thanks.
*** This bug has been marked as a duplicate of 7327 ***
Subject: Bug 11285 CVSROOT: /cvs/gcc Module name: gcc Changes by: mkoch@gcc.gnu.org 2005-04-27 21:03:00 Modified files: libjava : ChangeLog libjava/gnu/java/net/protocol/file: Connection.java libjava/java/net: URLClassLoader.java Log message: 2005-04-27 Chris Burdess <dog@gnu.org> * gnu/java/net/protocol/file/Connection.java: Return correct content length for directory listing. * java/net/URLClassLoader.java: Correction for URLClassLoader, bug #11285: return valid URLs for directories.i Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3568&r2=1.3569 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/gnu/java/net/protocol/file/Connection.java.diff?cvsroot=gcc&r1=1.10&r2=1.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/net/URLClassLoader.java.diff?cvsroot=gcc&r1=1.28&r2=1.29