public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "carlo at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/11953] _REENTRANT defined when compiling non-threaded code. Date: Tue, 29 Nov 2005 16:06:00 -0000 [thread overview] Message-ID: <20051129160558.2390.qmail@sourceware.org> (raw) In-Reply-To: <bug-11953-794@http.gcc.gnu.org/bugzilla/> ------- Comment #38 from carlo at gcc dot gnu dot org 2005-11-29 16:05 ------- That never works because it always defines _REENTRANT. You probably mean: #ifdef _REENTRANT #define GCC_BUGFIX 1 #endif #include <iostream> #undef _REENTRANT #ifdef GCC_BUGFIX #define _REENTRANT 1 #endif The drawback of this "fix" is that it is hardly usable for library writers like you and me. You can add this to every .cpp file of an application, but it doesn't help to determine if the _user_ (of your library) wants thread-safeness or not. Such a user will add -pthread when compiling his application but we cannot detect that anymore. We can also not demand that users of our library add the above kludge at the top of every .cpp file of their application (before any system headers are included) or, equivalently, demand they include the header of our library before any system header. That being said, I obviously agree completely with Marc that this is a bug: _REENTRANT should only be defined by the compiler iff -pthread is passed to the compiler. I know that is not a written standard, but it certainly is widely used and something developers have come to rely on so much that it is pure arrogance to break it. I'd say, ignorance-- but given the fact that I reported this BEFORE it was released (after running into it in a cvs version), and it was released anyway... Nevertheless-- I've seen enough of the gcc development (that is, what is related with C++) to know that 'we' cannot rely on (the) g++ (developers) being interested in keeping backwards compatibility with ANYTHING that isn't set in stone by some ISO committee (refering to some GNU extensions here). Therefore I suggest to everyone reading this: don't rely on common sense. The define of _REENTRANT isn't some standard and therefore you cannot not rely on it (when using g++). Even if it was fixed in 4.1, you can count on it being broken again in 4.2. The only reliable "solution" left is to demand that the users define a macro on the command line. So, expect to see this kind of compilations in the future: g++ -pthread -DBOOST_THREAD_SAFE -DLIBCWD_THREAD_SAFE -DLIBXML2_THREAD_SAFE -DLIBC_THREAD_SAFE -DLIBFOO_THREAD_SAFE -DLIBGTK_THREAD_SAFE [...] application.cc until some guru proposes that all libraries make use of one and the same define: GURU_THREAD_SAFE. Unfortunately... two decades later, once that macro made it's way into AX[3.4]UbuOS-6.8 and some bug needs it to be defined always... g++ will think it's allowed to unconditionally define GURU_THREAD_SAFE too... because it wasn't an official standard [...] Yeah, history repeats itself. Watch and see. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11953
next prev parent reply other threads:[~2005-11-29 16:06 UTC|newest] Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-11953-794@http.gcc.gnu.org/bugzilla/> 2005-10-07 3:12 ` gdr at gcc dot gnu dot org 2005-11-28 13:37 ` marc dot waeckerlin at siemens dot com 2005-11-29 9:14 ` marc dot waeckerlin at siemens dot com 2005-11-29 9:27 ` marc dot waeckerlin at siemens dot com 2005-11-29 9:34 ` marc dot waeckerlin at siemens dot com 2005-11-29 16:06 ` carlo at gcc dot gnu dot org [this message] 2006-02-17 21:49 ` jakub at gcc dot gnu dot org 2006-02-28 8:47 ` gdr at gcc dot gnu dot org 2006-10-05 16:06 ` debian-gcc at lists dot debian dot org 2006-12-11 18:13 ` dberlin at gcc dot gnu dot org 2006-12-12 15:15 ` jakub at gcc dot gnu dot org 2006-12-12 15:22 ` jakub at gcc dot gnu dot org 2006-12-12 15:24 ` jakub at gcc dot gnu dot org 2006-12-13 9:38 ` pinskia at gcc dot gnu dot org 2006-12-17 13:47 ` doko at gcc dot gnu dot org 2006-12-17 13:53 ` doko at gcc dot gnu dot org 2006-12-17 13:57 ` doko at gcc dot gnu dot org 2003-08-17 2:21 [Bug c++/11953] New: " carlo at alinoe dot com 2004-05-14 16:26 ` [Bug libstdc++/11953] " bangerth at dealii dot org 2004-05-14 17:08 ` ljrittle at gcc dot gnu dot org 2004-05-14 17:40 ` john at johnmaddock dot co dot uk 2004-05-15 20:34 ` pinskia at gcc dot gnu dot org 2004-05-19 10:33 ` ro at techfak dot uni-bielefeld dot de 2004-05-19 13:16 ` redi at gcc dot gnu dot org 2004-05-20 0:10 ` john at johnmaddock dot co dot uk 2004-06-09 19:18 ` mmitchel at gcc dot gnu dot org 2004-06-09 19:25 ` ro at techfak dot uni-bielefeld dot de 2004-06-09 19:30 ` Andrew Pinski 2004-06-09 19:30 ` pinskia at physics dot uc dot edu 2004-06-09 19:37 ` ro at techfak dot uni-bielefeld dot de 2004-06-18 23:41 ` mmitchel at gcc dot gnu dot org 2004-07-20 0:50 ` bkoz at gcc dot gnu dot org 2004-07-22 13:19 ` redi at gcc dot gnu dot org 2004-07-22 13:40 ` giovannibajo at libero dot it 2004-08-19 20:30 ` mmitchel at gcc dot gnu dot org 2004-09-10 15:25 ` pinskia at gcc dot gnu dot org 2004-10-08 13:13 ` redi at gcc dot gnu dot org 2004-10-08 13:53 ` carlo at gcc dot gnu dot org 2004-10-11 11:39 ` redi at gcc dot gnu dot org 2004-10-11 12:22 ` redi at gcc dot gnu dot org 2004-10-30 19:37 ` mmitchel at gcc dot gnu dot org 2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org 2005-06-13 3:29 ` pinskia at gcc dot gnu dot org 2005-06-14 13:19 ` cludwig at cdc dot informatik dot tu-darmstadt dot de 2005-07-15 22:05 ` pinskia at gcc dot gnu dot org 2005-07-29 11:26 ` david dot nospam dot hopwood at blueyonder dot co dot uk 2005-07-29 12:20 ` david dot nospam dot hopwood at blueyonder dot co dot uk 2005-07-29 13:35 ` redi at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20051129160558.2390.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).