public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6257: C-library symbols enter global namespace
@ 2002-04-25 13:56 Phil Edwards
0 siblings, 0 replies; 4+ messages in thread
From: Phil Edwards @ 2002-04-25 13:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/6257; it has been noted by GNATS.
From: Phil Edwards <phil@jaj.com>
To: marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/6257: C-library symbols enter global namespace
Date: Thu, 25 Apr 2002 16:46:39 -0400
On Thu, Apr 11, 2002 at 04:16:58PM -0000, marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp wrote:
> >Category: c++
This should be libstdc++, but GNATs won't let me fix that. Hmmm.
> >Release: unknown-1.0
This makes a difference. Lots of stuff changed between 2.x and 3.x.
> >Description:
> The C++ standard states that
> - all C++ header files define their symbols in namespace std
> - all C header files, used in the form <c*> define their symbol in
> namespace std (Annex D 5.2,3).
>
> However, g++ puts C symbols in the global namespace,
> even if included via <c**> headers.
We know. Interoperating with an arbitrary C library (which is what we are
required to do) is quite difficult. As yet very few people have volunteered
to work on a solution, and those that have volunteered have very little time.
Some of the partial solutions are in the source tree and can be turned on
with the appropriate --enable options.
To use your two examples, making this work on Linux should be much easier
than on Solaris.
> >Fix:
> Put all C symbols in the namespace std, if included
> by <c*> headers.
You realize, of course, that this is completely useless? "Fix the problem"
is an implied answer. If you'd like to help us work on an actual patch,
we'd be very grateful.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/6257: C-library symbols enter global namespace
@ 2002-04-12 0:46 Marc-Oliver Gewaltig
0 siblings, 0 replies; 4+ messages in thread
From: Marc-Oliver Gewaltig @ 2002-04-12 0:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/6257; it has been noted by GNATS.
From: Marc-Oliver Gewaltig <marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp>
To: Phil Edwards <phil@jaj.com>, gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/6257: C-library symbols enter global namespace
Date: Fri, 12 Apr 2002 09:44:33 +0200
Phil Edwards wrote:
> You need to give an actual version number here... the situation is better
> with GCC 3.x but is still problematic. If you are using 2.x then the library
> is very outdated.
Sorry, I think I put this somewhere.
I had this problem on
g++ 3.0.{2,3,4}
> However, g++ puts C symbols in the global namespace,
> > even if included via <c**> headers.
>
> Yes, we know. The problem is almost impossible to solve without control
> over the C library. Since we don't provide a C library -- your system
> vendor gives you that -- we cannot control its contents.
Actually, this issue was a problem for me on Linux, where string.h
defines a number of functions which are not part of standard C.
In particular char* index() gives me a headache, since it collides
with a typedef in my code.
My original problem was, that on Linux (with g++ 3.0.{2,3,4}, the
following does NOT compile, though it should. And on Linux, there is
at least some control over the C library, since it comes from GNU.
#include <iostream>
namespace test
{
typedef unsigned int index;
}
using test::index;
int main()
{
index i=5;
return 0;
}
Isn't it at least possible to threat code correctly which does not explicitly
include C headers?
>
> Various ideas have been proposed, but nobody has had time to implement them.
I had the naive idea that if
1. all c++ headers included only <c*> headers and
2. all <c*> headers wrap the <*.h> includes in namespace std
the problem should be solved, but maybe I am missing something...
> > >Fix:
> > Put all C symbols in the namespace std, if included
> > by <c*> headers.
>
> You do realize that this answer was completely useless? "Fix the problem"
> is an obvious and unhelpful response to "How to fix?"
Sorry, it was meant constructive (see above). As I said, I am
probably not deep enough in the matters.
>
> Now, if you have a /patch/, then that would be very helpful. :-)
>
Sorry again, but I will have a look... ;-)
Oliver
--
Dr. Marc-Oliver Gewaltig
Future Technology Research
==========================================================
Honda R&D Europe (Deutschland) GmbH
Carl-Legien-Str. 30
D-63073 Offenbach/Main, Germany
Telephone: +49 (0)69-89011-0 ext. -739
Telefax: +49 (0)69-89011-749
E-mail: marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp
marc-oliver_gewaltig@de.hrdeu.com
==========================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/6257: C-library symbols enter global namespace
@ 2002-04-11 12:36 Phil Edwards
0 siblings, 0 replies; 4+ messages in thread
From: Phil Edwards @ 2002-04-11 12:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/6257; it has been noted by GNATS.
From: Phil Edwards <phil@jaj.com>
To: marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/6257: C-library symbols enter global namespace
Date: Thu, 11 Apr 2002 15:35:31 -0400
On Thu, Apr 11, 2002 at 04:16:58PM -0000, marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp wrote:
> >Originator: marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp
> >Release: unknown-1.0
You need to give an actual version number here... the situation is better
with GCC 3.x but is still problematic. If you are using 2.x then the library
is very outdated.
> However, g++ puts C symbols in the global namespace,
> even if included via <c**> headers.
Yes, we know. The problem is almost impossible to solve without control
over the C library. Since we don't provide a C library -- your system
vendor gives you that -- we cannot control its contents.
Various ideas have been proposed, but nobody has had time to implement them.
> >Fix:
> Put all C symbols in the namespace std, if included
> by <c*> headers.
You do realize that this answer was completely useless? "Fix the problem"
is an obvious and unhelpful response to "How to fix?"
Now, if you have a /patch/, then that would be very helpful. :-)
Phil
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams
^ permalink raw reply [flat|nested] 4+ messages in thread
* c++/6257: C-library symbols enter global namespace
@ 2002-04-11 9:26 marc-oliver.gewaltig
0 siblings, 0 replies; 4+ messages in thread
From: marc-oliver.gewaltig @ 2002-04-11 9:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 6257
>Category: c++
>Synopsis: C-library symbols enter global namespace
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 11 09:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp
>Release: unknown-1.0
>Organization:
>Environment:
Linux (Suse 6.2), Solaris 8, probably all
>Description:
The C++ standard states that
- all C++ header files define their symbols in namespace std
- all C header files, used in the form <c*> define their symbol in
namespace std (Annex D 5.2,3).
However, g++ puts C symbols in the global namespace,
even if included via <c**> headers.
>How-To-Repeat:
The following version of hello-world should NOT compile
with an ISO-14882 compliant compiler
#include <cstdio>
int main()
{
// should not work, because printf is in std::
printf("Hello world.\n");
return 0;
}
>Fix:
Put all C symbols in the namespace std, if included
by <c*> headers.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-04-25 20:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-25 13:56 c++/6257: C-library symbols enter global namespace Phil Edwards
-- strict thread matches above, loose matches on Subject: below --
2002-04-12 0:46 Marc-Oliver Gewaltig
2002-04-11 12:36 Phil Edwards
2002-04-11 9:26 marc-oliver.gewaltig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).