From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20662 invoked by alias); 18 Apr 2006 15:10:56 -0000 Received: (qmail 20622 invoked by uid 48); 18 Apr 2006 15:10:52 -0000 Date: Tue, 18 Apr 2006 15:10:00 -0000 Message-ID: <20060418151052.20621.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug libstdc++/6257] C-library symbols enter global namespace In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "marc dot glisse at normalesup dot org" 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 X-SW-Source: 2006-04/txt/msg01438.txt.bz2 List-Id: ------- Comment #17 from marc dot glisse at normalesup dot org 2006-04-18 15:10 ------- (In reply to comment #15) > So there's a problem with the multiple-include-protection in glibc! Yes, the way it is done in solaris is way more convenient. There, stdlib.h includes a file iso/stdlib_iso.h that has all the meat, and then stdlib.h does all the using std::foo; stuff, so cstdlib can just include iso/stdlib_iso.h directly. On solaris, I get quite satisfactory results with: g++ -I/opt/SUNWspro/prod/include/CC/std -D__cplusplus=199711L -U__EXTENSIONS__ -D__STDC__=0 (the include directory contains the cstd headers from sunpro, but they are just one or 2 #include lines) > But we can't do this in any manner because they have multiple-include > protection which can't tell the difference. gcc could come with its own stdlib.h. Both this stdlib.h and cstdlib would include /usr/include/stdlib.h (always with _GLIBCPP_USE_NAMESPACES) and the gcc provided stdlib.h would additionally contain the appropriate using std::foo; lines. The 2 problems I see with this approach are: 1) it means having 2 files with the same name in the search path, and inclusion of the glibc file has to be done with an explicit path of /usr/include (or some other compile time constant) 2) This will do what we want for standard functions, but what about extensions that are declared in stdlib.h in glibc (protected by __USE_ISOC99 or __USE_GNU for example), what happens to them? It might work well, I have not tested. > At the beginning of stdio.h, instead of: > #ifndef _STDIO_H > #define _STDIO_H > we would have: > #if ( ( defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES ) \ > && ! defined _STDIO_H_WITH_NAMESPACES ) \ > || ( (! defined __cplusplus || ! defined _GLIBCPP_USE_NAMESPACES )\ > && ! defined _STDIO_H ) > #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES > # define _STDIO_H_WITH_NAMESPACES > #else > # define _STDIO_H > #endif This way you get 2 declarations instead of one and a using directive, I am not sure it won't cause problems (but I don't know). -- marc dot glisse at normalesup dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marc dot glisse at | |normalesup dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6257