[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] complex numbers and zeta function
From: |
Hongzheng Wang |
Subject: |
Re: [Help-gsl] complex numbers and zeta function |
Date: |
Sun, 22 Jun 2008 00:21:20 +0800 |
Yes, the syntax difference is indeed a problem.
C99's complex is a built-in type (_Complex is keyword now, and complex
is a synonym for it defined in complex.h), which guarantees that the
real and imag parts are allocated adjacently without gap. C++98 does
not have built-in complex type and complex is a template class and no
implementation details are given in standard.
I think it is not always a big problem. In gcc, for example, the
libstdc++'s complex.h (under /usr/include/c++/<version>/) is just an
include_next to gcc's complex.h (under /usr/include/). As a result,
if a C++ user includes complex.h rather than complex, he would get
C99's complex instead of template complex class in C++, which is not
desired but works. If the user sticks to standard C++, no such a
problem, since libstdc++'s complex.h will not be included at all.
The memory layout is a more serious problem in fact. I did some
experiments, and it seems that gsl's complex, C99's complex, and
C++98's complex have the same memory layout in gcc 4.3.1. But I have
not read the source codes of libstdc++, so I can not confirm it yet.
Well, even it is true, such a fact is only valid in gcc, given that
C++98's standard fails to provide implementation requirements for
template complex.
On Sat, Jun 21, 2008 at 11:09 PM, Jordi Gutiérrez Hermoso
<address@hidden> wrote:
> Syntax seems to be it. They have widely different syntax. There may
> also be implementation issues. The macro, unless C's complexes are not
> as standard as I think they are, is "complex", not "_Complex". The
> biggest problem, and maybe there is a way to override it, is that
> #include<complex.h> gets interpreted different ways depending if gcc
> is compiling the code as a C or a C++ program. As a C program, it
> includes the right declaration, and as a C++ program, it interprets it
> as an attempt to write #include <complex> and warns about deprecated
> headers.
>
> HTH,
> - Jordi G. H.
>
--
HZ
- Re: [Help-gsl] complex numbers and zeta function, (continued)
- Re: [Help-gsl] complex numbers and zeta function, Inigo Aldazabal Mensa, 2008/06/17
- Re: [Help-gsl] complex numbers and zeta function, Tommy Nordgren, 2008/06/18
- Re: [Help-gsl] complex numbers and zeta function, Ruben Henner Zilibowitz, 2008/06/19
- Re: [Help-gsl] complex numbers and zeta function, Jordi Gutiérrez Hermoso, 2008/06/19
- Re: [Help-gsl] complex numbers and zeta function, Ruben Henner Zilibowitz, 2008/06/20
- Re: [Help-gsl] complex numbers and zeta function, Jordi Gutiérrez Hermoso, 2008/06/20
- Re: [Help-gsl] complex numbers and zeta function, Ruben Henner Zilibowitz, 2008/06/20
- Re: [Help-gsl] complex numbers and zeta function, Hongzheng Wang, 2008/06/21
- Re: [Help-gsl] complex numbers and zeta function, Jordi Gutiérrez Hermoso, 2008/06/21
- Re: [Help-gsl] complex numbers and zeta function,
Hongzheng Wang <=