I am trying to use FFTW in a Nim project. The main API is exposed under the header fftw3.h.
In order to use it from Nim, I am running c2nim on the header file, getting fftw-3.3.4/api/fftw3.h(60, 57) Error: ';' expected. The error at the end of the second line here
#if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I)
# define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C
#else
# define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2]
#endif
I tried the obvious fix of adding a ; at the end, but the error stays the same.
Did anyone try to use FFTW from Nim before? Any ideas how to make the header parse?
Thank you Araq. I tried to follow the guide and managed to make it parse.
Unfortunately, the resulting Nim file defines everything as fftwf_name. I get plenty of sections like this
var fftw_name*: ptr char
var fftw_name*: ptr char
var fftw_name*: ptr char
type
fftwf_name* = ptr fftwf_name
fftwf_name* = fftw_iodim_do_not_use_me
fftwf_name* = fftw_iodim64_do_not_use_me
fftwf_name* = fftw_r2r_kind_do_not_use_me
fftwf_name* = fftw_write_char_func_do_not_use_me
fftwf_name* = fftw_read_char_func_do_not_use_me
proc fftwf_name*(p: fftwf_name)
proc fftwf_name*()
proc fftwf_name*()
proc fftwf_name*(t: cdouble)
proc fftwf_name*(nthreads: cint)
proc fftwf_name*(): cint
proc fftwf_name*()
It looks like something has gone wrong in translating the header, but I am not experienced enough in C to find out what happened.
I do not expect anyone to try and fix the header for me, but maybe it is useful for you to have examples where c2nim fails, in order to improve the robustness of the tool.
Hi Andrea,
I'm really sorry, I created Nim bindings for FFTW3 a few weeks ago, but my laziness prevented me from adding them to the Nimble repository. I was reluctant to announce them here because I discovered that a few functions defined in the version I use (3.3.4) are not available in older releases (the other version I found problematic is 3.2.2), and therefore their usage might not be straightforward on older systems. Since I developed these bindings with the purpose to use them in a program I am writing, I solved my problems by purging out every function I did not need for the program itself (this spared just a handful of functions).
The original FFTW3 bindings I wrote are available here: https://github.com/ziotom78/nimfftw3
I also created a PR to make the package available through Nimble: https://github.com/nim-lang/packages/pull/158
Maurizio.