警告:从不兼容的指针类型传递参数[默认启用]

我一直在寻找其他线程与某些有关的,但不知何故,我只是不明白…

我想对我已经评估的一组值做一些FFT,并写这个程序来首先读取值并将它们保存到大小为n的数组.

int main () {
    // some variables and also a bit of code to read the 'messwerte.txt'

printf("Geben sie an wieviele Messwerte ausgelesen werden sollen: ");
scanf("%d",&n);
double werte[n]; //Array der "fertigen" Messwerte
in = fopen ("messwerte.txt","r");
double nul[n]; //Array von nullen

int logN = 14;
l=FFT(logN,&werte,&nul);
}

在同一个文件中,我也在这个程序的帮助下做FFT:

double FFT (int logN,double *real,double *im) //logN is base 2 log(N) {
// blabla FFT calculation
}

但是,当我编译我总是得到这个错误

gcc FFT.c -lm
FFT.c: In function ‘main’:
FFT.c:94:2: warning: passing argument 2 of ‘FFT’ from incompatible pointer type [enabled by default]
FFT.c:4:8: note: expected ‘double *’ but argument is of type ‘double (*)[(unsigned int)(n)]’
FFT.c:94:2: warning: passing argument 3 of ‘FFT’ from incompatible pointer type [enabled by default]
FFT.c:4:8: note: expected ‘double *’ but argument is of type ‘double (*)[(unsigned int)(n)]’

既然这是我第一次编程,我真的不知道我的代码有什么问题.我必须为编译器或类似的东西设置更多的标志(因为我不得不做这个-lm的东西,或者它不会编译,并且说如pow没有找到的东西)?

此外,我知道在Windows或Linux机器上编写时可能会有所区别,如果是操作系统的问题,我使用的是Linux,Lubuntu 12.10 32位.

解决方法

werte []和nul []是数组,但werte本身就是数组的第一个元素的地址.所以当你做& werte你试图传递一个地址的地址(如@cnicutar指出,这应该实际上读取指向一个N个元素的数组). SO只是通过werte和nul没有符号标志来传递这些数组的地址.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...