标题: 敬请高手修改“基于STM32F4的电子阅读器”中的问题,感谢! [打印本页]

作者: zlkj    时间: 2021-4-6 12:17
标题: 敬请高手修改“基于STM32F4的电子阅读器”中的问题,感谢!
敬请高手修改“基于STM32F4的电子阅读器”中的问题,感谢!

源代码.7z

842.43 KB, 下载次数: 10


作者: 51hei团团    时间: 2021-4-6 14:59
贴错误截图看看,大家都是手机上的论坛无法下载编译
作者: zlkj    时间: 2021-4-6 15:25
compiling main.c...
main.c(253): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
          res=mf_open((char *)spr_name,FA_READ);//只读打开
main.c(447): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
                          if(mf_open(spr_buf,FA_OPEN_EXISTING)==FR_OK)
main.c(448): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "const u8 *"
                                  ai_load_picfile(spr_buf,60,100,150,250,1);        //显示图片1
main.c(461): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
                          if(mf_open(spr_buf,FA_OPEN_EXISTING)==FR_OK)
main.c(462): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "const u8 *"
                                  ai_load_picfile(spr_buf,280,100,150,250,1);
main.c(477): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
                          if(mf_open(spr_buf,FA_OPEN_EXISTING)==FR_OK)
main.c(478): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "const u8 *"
                                  ai_load_picfile(spr_buf,60,450,150,250,1);//显示图片3
main.c(492): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "u8 *"
                          if(mf_open(spr_buf,FA_OPEN_EXISTING)==FR_OK)
main.c(493): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "const u8 *"
                                  ai_load_picfile(spr_buf,280,450,150,250,1);//显示图片4
main.c(702): warning:  #940-D: missing return statement at end of non-void function "lcd_dis_files"
  }
main.c(959): warning:  #170-D: pointer points outside of underlying object
                          if(strncmp(txt_pathname[key-1]-4+strlen(txt_pathname[key-1]),".txt",4)==0)
main.c(1007): warning:  #167-D: argument of type "u8 *" is incompatible with parameter of type "const char *"
                  if(strcmp(path,txt_path_name[ i])==0)
main.c(1007): warning:  #167-D: argument of type "u8 *" is incompatible with parameter of type "const char *"
                  if(strcmp(path,txt_path_name[ i])==0)
main.c(1011): warning:  #167-D: argument of type "u8 *" is incompatible with parameter of type "char *restrict"
                                  strcpy(txt_path_name[j],txt_path_name[j+1]);
main.c(1011): warning:  #167-D: argument of type "u8 *" is incompatible with parameter of type "const char *restrict"
                                  strcpy(txt_path_name[j],txt_path_name[j+1])

作者: 聆烟雨    时间: 2021-4-7 14:51
我编译了一下 "..\OBJ\HZ.axf" - 0 Error(s), 18 Warning(s) :
没有错误,全是警告。 这是原子的代码吗? 如果是的话, 写代码就有些不负责任了,这是教学用的,要严谨一点。 不能没错误就完事了。

function "mf_open" declared implicitly  解决方法: main.c 头部增加 #include "fattester.h"

然后再编译, 15个警告


missing return statement at end of non-void function "lcd_dis_files"   解决方法: lcd_dis_files 函数最后加上 return 0;

pointer points outside of underlying object   解决方法: 想要没有警告很简单, txt_pathname[key-1]-4  这里, 去掉 -4  就可以。
   txt_pathname 是个字符串数组, 这里 txt_pathname[key-1] 是一个字符串指针, 我不清楚他把一个指针 -4 是做什么。 需要实际板子调试。


剩下的警告,都是形参实参类型不匹配导致的。 可以用强制类型转换解决。 但最好的办法是改成统一的定义和调用, 他这个代码像是拼凑起来的。

例如  mf_open((char*)spr_name,FA_READ);   改为  mf_open((u8*)spr_name,FA_READ);  就可以解决。
原因是 mf_open 定义的时候, 需要 u8* 作为参数, 而调用的时候, 给的参数是  char*, 所以有警告。

作者: zlkj    时间: 2021-4-8 12:51
聆烟雨 发表于 2021-4-7 14:51
我编译了一下 "..\OBJ\HZ.axf" - 0 Error(s), 18 Warning(s) :
没有错误,全是警告。 这是原子的代码吗? ...

感谢回复!按照你的修改后,还有一些警告怎么解决?敬请回复!
作者: ccccssss    时间: 2021-4-20 19:09
代码在f429的单片机里面可以直接用吗




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1