gpt4 book ai didi

c - 可疑指针转换警告

转载 作者:行者123 更新时间:2023-12-01 16:36:21 25 4
gpt4 key购买 nike

我正在使用 Microchip 的 C18 编译器编译我的 C 代码。我收到警告 [2054] suspicious pointer conversion在这段代码中:

unsigned char ENC_MAADR1 = 0x65;
unsigned char ENC_ReadRegister(unsigned char address);
// ...
puts(ENC_ReadRegister(ENC_MAADR1)); // <-- warning on this line

这个警告是什么意思,我该如何解决?

最佳答案

puts需要 const char* ,您正在交付unsigned char ,甚至没有指针。

来自 here :

#include <stdio.h> 

int puts(const char *s);
puts()函数写入 s 指向的字符串到标准输出流 stdout 并将换行符附加到输出。不写入字符串的终止空字符。

使用 putc(int c, FILE* stream)反而...
here供引用。

感谢您的注释!

关于c - 可疑指针转换警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16165477/

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