Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of function argument declaration does this C function has?

Tags:

c++

c

I'm Working on FFTW (Fastest Fourier Transform in the West) and came over this C function. I did not understand the declaration of this function where parameters are present inside ()(). I never saw a declaration as such. Can anyone brief it out?

void X(execute_dft_r2c)(const X(plan) p, R *in, C *out)
    {
      /*
       *Body
       */
    }
like image 984
aditya palavajjhala Avatar asked Dec 28 '25 22:12

aditya palavajjhala


1 Answers

X is a macro that adds a precision-naming prefix depending on compilation parameters.

I believe the point (at least one of them) is to avoid mismatches by causing errors if source files have been compiled with different precision settings.
(C does not have type-safe linkage.)

Look in fftw3/kernel/ifftw.h:

/* determine precision and name-mangling scheme */
#define CONCAT(prefix, name) prefix ## name
#if defined(FFTW_SINGLE)
  typedef float R;
# define X(name) CONCAT(fftwf_, name)
#elif defined(FFTW_LDOUBLE)
  typedef long double R;
# define X(name) CONCAT(fftwl_, name)
# define TRIGREAL_IS_LONG_DOUBLE
#elif defined(FFTW_QUAD)
  typedef __float128 R;
# define X(name) CONCAT(fftwq_, name)
# define TRIGREAL_IS_QUAD
#else
  typedef double R;
# define X(name) CONCAT(fftw_, name)
#endif

In the first case, your declaration expands to

void fftwf_execute_dft_r2c(const fftwf_plan p, R *in, C *out)
like image 158
molbdnilo Avatar answered Dec 31 '25 11:12

molbdnilo