奇怪的不兼容指针类型错误

orl*_*rlp 2 c types

我有这段看似无辜的代码:

void generate_heightmap(float **terrain) {

}

int main(int argc, char **argv) {
    float terrain[1500][1500];

    generate_heightmap(terrain);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试编译它时,我得到了这些奇怪的错误,这可能是什么原因?

test.c||In function ‘main’:|
test.c|8|warning: passing argument 1 of ‘generate_heightmap’ from incompatible pointer type [enabled by default]|
test.c|1|note: expected ‘float **’ but argument is of type ‘float (*)[1500]’|
||=== Build finished: 1 errors, 1 warnings ===|
Run Code Online (Sandbox Code Playgroud)

我有GCC 4.6.1和Ubuntu 11.11 64位.

Oli*_*rth 5

2D数组与双指针不兼容(考虑如何在内存中布置2D数组,以及如何将索引编入其中需要了解其中一个维度).

这个精确的主题在C FAQ的问题6.18中处理.