Sunday, February 21, 2016

Digest for comp.lang.c++@googlegroups.com - 24 updates in 5 topics

Marcel Mueller <news.5.maazl@spamgourmet.org>: Feb 21 03:22PM +0100

I have some compatibility issues regarding complex.h in an FFTW3
application.
 
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>
This is deprecated but so far all relevant compilers supported the old
header files for compatibility. The code is quite old (~15 years) and
not namespace aware. I only upgraded to FFTW3 several years ago.
 
But now I try to switch to a newer compiler (gcc 4.8) and this raises a
conflict with the C99 compatibility header complex.h. Of course, this
does not support the resulting type definition in fftw3.h (compiled with -E)
typedef __complex__<long double> fftwl_complex;
 
The fftw3.h behaves differently when included from C++. This is an
application specific patch.
 
#ifdef __cplusplus
/* In C++ mode prefer class complex<> */
#include <complex.h>
# define FFTW_DEFINE_COMPLEX(R, C) typedef complex<R> C
extern "C"
{
#else /* __cplusplus */
/* If <complex.h> is included, use the C99 complex type. Otherwise
define a type bit-compatible with C99 complex */
#ifdef _Complex_I
# define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C
#else
# define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2]

No comments: