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 <[EMAIL PROTECTED]> 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 _______________________________________________ Help-gsl mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gsl
