相关疑难解决方法(0)

C函数const多维数组参数中的奇怪警告

我对这段代码有一些奇怪的警告:

typedef double mat4[4][4];

void mprod4(mat4 r, const mat4 a, const mat4 b)
{
/* yes, function is empty */
}

int main()
{
    mat4 mr, ma, mb;
    mprod4(mr, ma, mb);
}
Run Code Online (Sandbox Code Playgroud)

gcc 输出如下:

$ gcc -o test test.c
test.c: In function 'main':
test.c:13: warning: passing argument 2 of 'mprod4' from incompatible pointer
type
test.c:4: note: expected 'const double (*)[4]' but argument is of type 'double
(*)[4]'
test.c:13: warning: passing argument 3 of 'mprod4' from incompatible pointer
type
test.c:4:
note: …
Run Code Online (Sandbox Code Playgroud)

c arguments const function multidimensional-array

7
推荐指数
2
解决办法
5086
查看次数

标签 统计

arguments ×1

c ×1

const ×1

function ×1

multidimensional-array ×1