编译时出错:从'void*'到'unsigned char*'的转换无效



我正在编程Arduino mega 2560。我买了一个tft液晶显示器,我想用一个SD卡,这样我就可以把我的照片放在上面。

我下载了这个库,但是它给我错误。

<>之前C:Arduinolibrariespffpff.cpp:在函数'FRESULT pf_read(void*, short unsigned int, short unsigned int*)':C:Arduinolibrariespffpff.cpp:585:错误:从'void*'转换为'unsigned char*'无效之前

问题在这里:

pff.cpp:

 FRESULT pf_read (
    void* buff,     /* Pointer to the read buffer (NULL:Forward data to the stream)*/
    WORD btr,       /* Number of bytes to read */
    WORD* br        /* Pointer to number of bytes read */
)

pff.h:

FRESULT pf_read (void*, WORD, WORD*);           /* Read data from the open file */

当我把它变成。c文件时,它会给我更多的错误,像这样:<>之前tft_menu.cpp。0:在函数open_root_dir()中:C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:594:未定义引用' pf_opendir(_DIR_*, char const*)'tft_menu.cpp。在函数' mount_sd()'中:C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:583:未定义引用"disk_initialize()"C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:585:未定义引用"pf_mount(_FATFS_*)"tft_menu.cpp。在函数bitmap_show(char*)中:C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:472:未定义引用' pf_open(char const*)'C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:476:未定义引用' pf_read(void*, unsigned short, unsigned short*)'C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:518:未定义引用' pf_read(void*, unsigned short, unsigned short*)'tft_menu.cpp。在函数' show_bitmap()'中:C:AppDataLocalTempbuild7310099894910129341.tmp/tft_menu.cpp:603:未定义引用' pf_readdir(_DIR_*, _FILINFO_*)'之前

所以我认为它应该被编译成一个cpp。

编辑:

我发现我必须将其保存为cpp并且在程序中我必须写下icktofay的状态

之后,我发现了一些错误,所以我转到第585行,如上所述,并更改了

BYTE *rbuff = buff;

BYTE rbuff = (unsigned char) buff;

我发现我必须添加mcc.h来消除"无法找到资源"的错误。

现在我得到这些错误:

C:librariesmmc/mmc.h: In function 'void init_spi()':
C:librariesmmc/mmc.h:21: error: 'PORTL' was not declared in this scope
C:librariesmmc/mmc.h:21: error: 'PORTL0' was not declared in this scope
C:librariesmmc/mmc.h:22: error: 'PORTB' was not declared in this scope
C:librariesmmc/mmc.h:22: error: 'PORTB2' was not declared in this scope
C:librariesmmc/mmc.h:22: error: 'PORTB1' was not declared in this scope
C:librariesmmc/mmc.h:23: error: 'DDRB' was not declared in this scope
C:librariesmmc/mmc.h:23: error: 'PORTB0' was not declared in this scope
C:librariesmmc/mmc.h:25: error: 'DDRL' was not declared in this scope
C:librariesmmc/mmc.h:27: error: 'SPCR' was not declared in this scope
C:librariesmmc/mmc.h:27: error: 'SPE' was not declared in this scope
C:librariesmmc/mmc.h:27: error: 'MSTR' was not declared in this scope
C:librariesmmc/mmc.h:28: error: 'SPSR' was not declared in this scope
C:librariesmmc/mmc.h:28: error: 'SPI2X' was not declared in this scope

我试着在mcc.h上面添加#include TFT_ARDUINO_MEGA.h,但仍然没有运气

将其编译为C文件,但在使用它的文件中,像这样包含pff.h:

extern "C" {
#include <pff.h>
}

最新更新