我在C中为Parallax Propeller编写了一个FFT,它不会编译。我认为这是一个问题,我如何使用结构(我是C的新手,将所有这些都从Clojure中翻译出来),但我甚至无法隔离问题来解决问题。删除代码的某些部分允许它编译,但我无法做出正面或反面。我已经在结构和数组上查找了所有内容,现在我需要更多的帮助!谢谢!
编译器错误在最后发布。
#include "simpletools.h"
#include "math.h"
#include "complex.h"
void fft();
int pow2(int exp); // Added to fix one of two problems
float complex ibi[256];
int main(void)
{
for(int i = 0; i < 256; i++)
{
ibi[i] = 1.0 + 1.0 * I;
}
}
void fft()
{
int log2n = 8;
int length = 256;
float pi = 3.1415;
for(int i = 0; i< log2n; i++)
{
int n1 = pow2(i);
int n2 = pow2(i + 1);
for (int j = 0; j< n1; j++)
{
for (int k = j; k < length; k= k + n2)
{
int k2 = k + n1;
float complex dw, nw, df, nf;
float da = pi * j / n1;
float na = pi * (n1 + j) / n1;
dw = cos(da) + -sin(da) * I;
nw = cos(na) + -sin(na) * I;
df = ibi[k2] * dw;
nf = ibi[k2] * nw;
ibi[k2] = ibi[k] + nf;
ibi[k] = ibi[k] + df;
}
}
}
}
int pow2(int exp)
{
int answer = 2;
for(int i = 0; i< exp; i++)
{
answer = answer * 2;
}
return answer;
}
编译时出错:
propeller-elf-gcc -v GCC 4.6.1 (propellergcc_v1_0_0_2261)
propeller-elf-gcc -I . -L . \
-I /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools \
-L /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ \
-I /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext \
-L /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/cmm/ \
-I /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c \
-L /home/steffan/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ \
-o cmm/ECG2.elf -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 \
ECG2.c -lsimpletools -lsimpletext -lsimplei2c -lsimpletools -lsimpletext \
-lsimpletools
/tmp/ccdKeRAK.o: In function `.L9':
(.text+0x97): undefined reference to `_cexpf'
/tmp/ccdKeRAK.o: In function `.L9':
(.text+0xba): undefined reference to `_cexpf'
collect2: ld returned 1 exit status
Done. Build Failed!
Check source for bad function call or global variable name `_cexpf'
/tmp/ccdKeRAK.o: In function `.L9':
(.text+0xba):