Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #41180
| From | bartekltg <bartekltg@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: C++ complex.h protability |
| Date | 2016-02-23 20:41 +0100 |
| Organization | ATMAN - ATM S.A. |
| Message-ID | <naiclt$th0$1@node1.news.atman.pl> (permalink) |
| References | (1 earlier) <nacm34$9hk$1@dont-email.me> <nad1ku$a8d$1@gwaiyur.mb-net.net> <nad8m4$knj$1@dont-email.me> <nahaab$hpn$1@node1.news.atman.pl> <nai964$1ol$1@dont-email.me> |
On 23.02.2016 19:45, Alf P. Steinbach wrote: > On 23.02.2016 10:55, bartekltg wrote: >> On 21.02.2016 22:05, Alf P. Steinbach wrote: >>> On 21.02.2016 20:02, Marcel Mueller wrote: >>>> On 21.02.16 16.48, Alf P. Steinbach wrote: >>>>>> In fact older C++ compilers required the include files with the .h >>>>>> extension (and no namespace std::), i.e. >>>>>> #include <math.h> >>>>>> #include <complex.h> >>>>> >>>>> I believe the requirement had to be imposed by the FFTW3 headers. >>>>> >>>>> No compilers can have imposed this requirement. >>>> >>>> 15 to 20 years ago all you get by #include <math> was "File not found". >>> >>> There is no standard library header <math> and never has been. >>> >>> There is a C++ standard library header <complex>. It's different from >>> <ccomplex> and <complex.h>. >> >> It has changed ;-) > > No. Not as far as I know. :) In gcc 5.2.1, ccomplex: #pragma GCC system_header #ifndef _GLIBCXX_CCOMPLEX #define _GLIBCXX_CCOMPLEX 1 #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #endif #include <complex> #endif It looks like, as stated in 26.4.11, including <ccomplex> has the same effect as including <complex>. Hmm. complex.h is... strange ;-) ... #if __cplusplus >= 201103L # include <ccomplex> #endif #if _GLIBCXX_HAVE_COMPLEX_H # include_next <complex.h> # ifdef _GLIBCXX_COMPLEX // See PR56111, keep the macro in C++03 if possible. # undef complex # endif #endif So it may be replaced by c++ <complex>. IMHO strange decision >> "26.4.11 Header <ccomplex> [ccmplx] >> 1 The header behaves as if it simply includes the header <complex>." > > Points to understand the above quote, which is of C++11 §26.4.10/1: Yes, I have looked at c++14 draft, in versions n3242.pdf n3376.pdf it is 26.4.10 > • The header <ccomplex> is not the header <complex>. Of course. This is a different file. The effect are the sama. > • The header <ccomplex> is the basic C++ variant of the /C header/ > <complex.h>. It places the C declarations in namespace std. It may also > place them in the global namespace. I'm lost. You just corrected me in which paragraph the standard say "The header behaves as if it simply includes the header <complex>.". > • The /C++ header/ <complex.h>, distinct from the C header <complex.h> > (same name, yes), is defined in terms of <ccomplex> instead of directly > in terms of the C header. The C++ header <complex.h> provides the same > contents as <ccomplex> except that it provides this content in the > global namespace. It may also provide the contents in the std namespace. > > And yes, I agree, the complexity of this is really ridiculous. The > original C++98 idea was evidently to not-so-subtly-at-all encourage a > move from “foo.h” headers to header names without filename extensions > “cfoo”. At that time C++ <ccomplex> was not allowed to pollute the > global namespace. But that did not sit well with compiler vendors, who > saw no reason to jump through hoops with additional extreme complexity, > with no evident advantage other than maybe supporting some idealistic > notions about filenames, so with C++11 the rules were changed to make > the <ccomplex> and <complex.h> requirements symmetric (and ditto for all > other such header pairs), incidentally making the whole thing > /meaningless/. So, just include <complex.h>, and forget about the > <ccomplex> complexity, so to speak – but remember that this is the > /C++ version/ of <complex.h>, and so it can, at the implementation's > discretion, make code that uses std:: qualifications compile, even > though that will not compile with some other compiler. :( Wow;-) > Relevant: > > C++11 §17.6.1.2: > > <quote> > Except as noted in Clauses 18 through 30 and Annex D, the contents of > each header cname shall be the same as that of the corresponding header > name.h, as specified in the C standard library (1.2) or the C Unicode > TR, as appropriate, as if by inclusion. In the C ++ standard library, > however, the declarations (except for names which are defined as macros > in C) are within namespace scope (3.3.6) of the namespace std. It is > unspecified whether these names are first declared within the global > namespace scope and are then injected into namespace std by explicit > using-declarations (7.3.3). > </quote> Does that mean complex.h and ccomplex (I have pasted fragments) from new gcc are broken according to the standard? best bartekltg
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C++ complex.h protability Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-21 15:22 +0100
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-21 16:48 +0100
Re: C++ complex.h protability Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-21 20:02 +0100
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-21 14:25 -0500
Re: C++ complex.h protability Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-21 23:43 +0100
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-21 20:44 -0500
Re: C++ complex.h protability Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-22 19:38 +0100
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-22 14:14 -0500
Re: C++ complex.h protability Cholo Lennon <chololennon@hotmail.com> - 2016-02-22 16:36 -0300
Re: C++ complex.h protability Ian Collins <ian-news@hotmail.com> - 2016-02-23 08:53 +1300
Re: C++ complex.h protability Cholo Lennon <chololennon@hotmail.com> - 2016-02-22 17:03 -0300
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-22 15:16 -0500
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-22 21:38 +0100
Re: C++ complex.h protability Cholo Lennon <chololennon@hotmail.com> - 2016-02-22 17:50 -0300
Re: C++ complex.h protability Cholo Lennon <chololennon@hotmail.com> - 2016-02-22 18:09 -0300
Re: C++ complex.h protability legalize+jeeves@mail.xmission.com (Richard) - 2016-02-22 21:20 +0000
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-22 12:47 -0800
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-22 16:18 -0500
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-22 13:51 -0800
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-22 16:57 -0500
Re: C++ complex.h protability legalize+jeeves@mail.xmission.com (Richard) - 2016-02-22 22:16 +0000
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-22 15:09 -0800
Re: C++ complex.h protability Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-22 19:53 -0500
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-22 23:23 -0800
Re: C++ complex.h protability Robert Wessel <robertwessel2@yahoo.com> - 2016-02-22 02:54 -0600
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-21 22:05 +0100
Re: C++ complex.h protability bartekltg <bartekltg@gmail.com> - 2016-02-23 10:55 +0100
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-23 19:45 +0100
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-23 19:55 +0100
Re: C++ complex.h protability bartekltg <bartekltg@gmail.com> - 2016-02-23 20:41 +0100
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-23 22:26 +0100
Re: C++ complex.h protability Christian Gollwitzer <auriocus@gmx.de> - 2016-02-22 08:16 +0100
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-22 02:06 -0800
Re: C++ complex.h protability Ian Collins <ian-news@hotmail.com> - 2016-02-22 09:00 +1300
Re: C++ complex.h protability Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-02-21 23:51 +0100
Re: C++ complex.h protability Öö Tiib <ootiib@hot.ee> - 2016-02-21 15:41 -0800
Re: C++ complex.h protability "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-02-22 00:50 +0100
csiph-web