gpt4 book ai didi

c - 如何修复编译器错误 ': warning: assignment makes integer from pointer without a cast'

转载 作者:太空宇宙 更新时间:2023-11-04 08:55:37 24 4
gpt4 key购买 nike

我下面的代码给了我一个警告:

warning: assignment makes integer from pointer without a cast":

uint16_t b[4];
uint16_t *g_00;
uint16_t *g_01;
uint16_t *g_10;
uint16_t *g_11;


b[0] = g_00;
b[1] = g_01;
b[2] = g_10;
b[3] = g_11;

printf ("add = %x\n", b[0]);

我打算用b[0]... b[1]来保存uint16_t *g_00;的地址

如何修复此编译器警告?

最佳答案

I meant to use b[0]... b[1] to save the address of uint16_t *g_00;

要在 b 的条目中存储地址,您需要将其声明为指针数组:

uint16_t ** b[4];

uint16_t * g_00;
...

b[0] = &g_00; /* Stores g_00's address. */

更新:

OP 的声明:

b[0] = g_00;

存储g_00的地址,而是g_00自身携带的值。

如果这是有意的(与存储 g_00' address 不同),b 的正确声明将是:

uint16_t * b[4];

uint16_t * g_00;
...

b[0] = g_00; /* Stores g_00's value. */

关于c - 如何修复编译器错误 ': warning: assignment makes integer from pointer without a cast',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17325850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com