Reputation: 117
Here is my problem, I must be missing something here.
const int nfft = 256 * 1024;
const float samplefrequency = 256.0 * 1024.0 ; // Hz
/* The buffer, spectral and data arrays for the FFT */
kiss_fft_cfg mybuff;
kiss_fft_cpx samples[nfft];
kiss_fft_cpx fftoutput[nfft];
/* The final, averaged spectrum */
double finalspec[nfft/2];
So this is a part of my code.
The problem is that i can't compile it because of : "error C2057: expression constante attendue" line 16 - kiss_fft_cpx samples[nfft]; "error C2057: constant expression required"
I don't understand what is wrong considering the fact that nfft is a constant.
Thanks
Upvotes: 1
Views: 2809
Reputation: 182684
I don't understand what is wrong considering the fact that nfft is a constant
In C const
variables aren't really constants, more like read-only objects. As such, they can't be used in all the places where true constants could be used (for example the size of an array).
Perhaps you could use a macro instead:
#define NFFS (256 * 1024)
Incidentally there's also a C FAQ entry on this subject: I don't understand why I can't use const values in initializers and array dimensions.
Upvotes: 2