Arduino,了解无效的转换警告,将未签名的char转换为char *

时间:2020-10-13 12:55:02

标签: c++ arduino type-conversion warnings platformio

编辑:

解决,两天不能接受我的答案


我正在使用PlatformIO对Arduino Nano进行编程,以将消息写入OLED显示器。

我正在调用函数printWeight

void printWeight(
        float weight,
        uint8_t scale=3,
        uint8_t numbd=3,
        uint8_t numad=2,
        bool kg=false,
        const char* description_text_line="Weight:",
        uint8_t width_per_character=5+1,
        uint8_t height_per_line=7+3
        ){
    ...

该功能通过计算前导空格leading_space来使文本居中,并在屏幕上无法显示消息时以较小的比例(scale-1)进行调用:

if(leading_space < 0){
        printWeight(weight, scale-1, numbd, numad, description_text_line,
                width_per_character, height_per_line);
        return;
    }

代码可以编译并正常运行。但是,我收到以下警告,我不知道如何解决:

src/main.cpp: In function 'void printWeight(float, uint8_t, uint8_t, uint8_t, bool, const char*, uint8_t, uint8_t)':
src/main.cpp:138:53: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'const char*' [-fpermissive]
                 width_per_character, height_per_line);
                                                     ^
src/main.cpp:93:6: note:   initializing argument 6 of 'void printWeight(float, uint8_t, uint8_t, uint8_t, bool, const char*, uint8_t, uint8_t)'
 void printWeight(
      ^

如何摆脱此警告?

1 个答案:

答案 0 :(得分:0)

缺少参数... 感谢那些人的评论。

相关问题