为什么我收到“不兼容的整数指针...”警告?

问题描述 投票:0回答:1

我只是尝试使用指针来获取数组第一个的地址并逐个读取元素。我使用指针不占用大部分内存。这是变量:

unsigned char *RawAudio;
extern const unsigned char bootup[];

我在这里收到警告:

*RawAudio = bootup;

这是我收到的警告: enter image description here

为什么?怎么算出来的?

c pointers keil
1个回答
0
投票
  1. 两个问题。您将指针分配给 unsigned char (
    *RawAudio = bootup;
    ),但我认为这是一个拼写错误。你需要
    RawAudio = bootup;
  2. 当您
    RawAudio = bootup;
    时,
    RawAudio
    指针将引用
    const
    对象。修改
    const
    对象会调用未定义行为。编译器将发出警告 - 您可能希望将其静音(如果使用显式强制转换)
© www.soinside.com 2019 - 2024. All rights reserved.